mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-25 18:39:00 +02:00
gmessages: Error if g_log_set_writer_func() is called multiple times
Inspired by https://gitlab.gnome.org/GNOME/glib/-/issues/2638. This requires moving the tests to subprocesses, so that `g_log_set_writer_func()` is only called once per process. It also adds a test for the new error. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
@@ -2059,9 +2059,18 @@ g_log_set_writer_func (GLogWriterFunc func,
|
||||
g_return_if_fail (func != NULL);
|
||||
|
||||
g_mutex_lock (&g_messages_lock);
|
||||
|
||||
if (log_writer_func != g_log_writer_default)
|
||||
{
|
||||
g_mutex_unlock (&g_messages_lock);
|
||||
g_error ("g_log_set_writer_func() called multiple times");
|
||||
return;
|
||||
}
|
||||
|
||||
log_writer_func = func;
|
||||
log_writer_user_data = user_data;
|
||||
log_writer_user_data_free = user_data_free;
|
||||
|
||||
g_mutex_unlock (&g_messages_lock);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user