From 5c2fb3762f9174d78213b2b2d8934883919b4f67 Mon Sep 17 00:00:00 2001 From: Tim Janik Date: Sun, 17 Jan 1999 14:52:20 +0000 Subject: added a define G_HOOK_DEFERRED_DESTROY, to substitute a noop Sun Jan 17 14:13:52 1999 Tim Janik * 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. --- ghook.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'ghook.c') diff --git a/ghook.c b/ghook.c index fae692796..7e1c82dea 100644 --- a/ghook.c +++ b/ghook.c @@ -131,10 +131,15 @@ g_hook_destroy_link (GHookList *hook_list, hook->hook_id = 0; hook->flags &= ~G_HOOK_FLAG_ACTIVE; if (hook_list->hook_destroy) - hook_list->hook_destroy (hook_list, hook); + { + if (hook_list->hook_destroy != G_HOOK_DEFERRED_DESTROY) + hook_list->hook_destroy (hook_list, hook); + } else if (hook->destroy) { hook->destroy (hook->data); + hook->data = NULL; + hook->func = NULL; hook->destroy = NULL; } g_hook_unref (hook_list, hook); /* counterpart to g_hook_insert_before */ -- cgit v1.2.3