diff --git a/glib/gmain.c b/glib/gmain.c index 9c5f0ef1e..15581ee7a 100644 --- a/glib/gmain.c +++ b/glib/gmain.c @@ -3125,10 +3125,10 @@ g_main_current_source (void) * { * SomeWidget *self = data; * - * GDK_THREADS_ENTER (); + * g_mutex_lock (&self->idle_id_mutex); * // do stuff with self * self->idle_id = 0; - * GDK_THREADS_LEAVE (); + * g_mutex_unlock (&self->idle_id_mutex); * * return G_SOURCE_REMOVE; * } @@ -3136,9 +3136,19 @@ g_main_current_source (void) * static void * some_widget_do_stuff_later (SomeWidget *self) * { + * g_mutex_lock (&self->idle_id_mutex); * self->idle_id = g_idle_add (idle_callback, self); + * g_mutex_unlock (&self->idle_id_mutex); * } * + * static void + * some_widget_init (SomeWidget *self) + * { + * g_mutex_init (&self->idle_id_mutex); + * + * // ... + * } + * * static void * some_widget_finalize (GObject *object) * { @@ -3147,6 +3157,8 @@ g_main_current_source (void) * if (self->idle_id) * g_source_remove (self->idle_id); * + * g_mutex_clear (&self->idle_id_mutex); + * * G_OBJECT_CLASS (parent_class)->finalize (object); * } * ]| @@ -3163,12 +3175,12 @@ g_main_current_source (void) * { * SomeWidget *self = data; * - * GDK_THREADS_ENTER (); + * g_mutex_lock (&self->idle_id_mutex); * if (!g_source_is_destroyed (g_main_current_source ())) * { * // do stuff with self * } - * GDK_THREADS_LEAVE (); + * g_mutex_unlock (&self->idle_id_mutex); * * return FALSE; * }