diff options
author | Tim Janik <timj@gtk.org> | 1999-01-17 14:52:20 +0000 |
---|---|---|
committer | Tim Janik <timj@src.gnome.org> | 1999-01-17 14:52:20 +0000 |
commit | 5c2fb3762f9174d78213b2b2d8934883919b4f67 (patch) | |
tree | 75e90b89315b0eabead2fda2c151e3a298a9ff2e /gmain.c | |
parent | 04d3d1b219347582f55b712b1fbe98fa26d22d84 (diff) |
added a define G_HOOK_DEFERRED_DESTROY, to substitute a noop
Sun Jan 17 14:13:52 1999 Tim Janik <timj@gtk.org>
* glib.h: added a define G_HOOK_DEFERRED_DESTROY, to substitute a noop
GHookList.hook_destroy function.
* ghook.c (g_hook_destroy_link): don't really call hook_destroy if it
is G_HOOK_DEFERRED_DESTROY. for the case where we invoke hook->destroy()
we now clean up the hook completely afterwards, i.e. data, func and
destroy are immediately set to NULL and hook_free can't play with that
values anymore.
* gmain.c (g_source_add): set hook_destroy to G_HOOK_DEFERRED_DESTROY,
instead of using an ugly _noop() hack, this is to avoid an uneccessary
function invokation. set hook_free to g_source_destroy_func, this way
we always invoke the destroy notifiers for user_data and source_data
after execution of dispatch(). thus, g_source_destroy_func() will always
be called within the main_loop lock (this wasn't really assured
before), and can release and reaquire the look around destroy notifier
invokation.
Diffstat (limited to 'gmain.c')
-rw-r--r-- | gmain.c | 18 |
1 files changed, 7 insertions, 11 deletions
@@ -400,7 +400,7 @@ g_source_compare (GHook *a, return (source_a->priority < source_b->priority) ? -1 : 1; } -/* HOLDS: main_loop_lock */ +/* HOLDS: main_loop lock */ static void g_source_destroy_func (GHookList *hook_list, GHook *hook) @@ -421,12 +421,6 @@ g_source_destroy_func (GHookList *hook_list, G_LOCK (main_loop); } -static void -g_source_noop (GHookList *hook_list, - GHook *hook) -{ -} - guint g_source_add (gint priority, gboolean can_recurse, @@ -441,12 +435,14 @@ g_source_add (gint priority, G_LOCK (main_loop); if (!source_list.is_setup) - g_hook_list_init (&source_list, sizeof(GSource)); + { + g_hook_list_init (&source_list, sizeof (GSource)); - source_list.hook_destroy = g_source_noop; - source_list.hook_free = g_source_destroy_func; + source_list.hook_destroy = G_HOOK_DEFERRED_DESTROY; + source_list.hook_free = g_source_destroy_func; + } - source = (GSource *)g_hook_alloc (&source_list); + source = (GSource*) g_hook_alloc (&source_list); source->priority = priority; source->source_data = source_data; source->hook.func = funcs; |