+Mon Dec 21 21:48:29 1998 Tim Janik <timj@gtk.org>
+
+ * glib.h:
+ * gmain.c: there was a reference count race for hooks during invocation
+ loops. since all (known) hook loop implementations, do currently start
+ out with g_hook_first_valid() and iterate with g_hook_next_valid(),
+ g_hook_first_valid() will now return a referenced hook, and
+ g_hook_next_valid() will "eat" that, and eventually transfer it to
+ the next hook. <sigh> unfortunately this requires g_hook_next_valid()
+ to take the hook_list as additional argument.
+
+ * gmain.c (g_main_iterate): adjusted callers of g_hook_next_valid().
+
Mon Dec 21 03:48:04 1998 Tim Janik <timj@gtk.org>
* gmain.c (g_main_iterate): default initialize source_timeout with -1
+Mon Dec 21 21:48:29 1998 Tim Janik <timj@gtk.org>
+
+ * glib.h:
+ * gmain.c: there was a reference count race for hooks during invocation
+ loops. since all (known) hook loop implementations, do currently start
+ out with g_hook_first_valid() and iterate with g_hook_next_valid(),
+ g_hook_first_valid() will now return a referenced hook, and
+ g_hook_next_valid() will "eat" that, and eventually transfer it to
+ the next hook. <sigh> unfortunately this requires g_hook_next_valid()
+ to take the hook_list as additional argument.
+
+ * gmain.c (g_main_iterate): adjusted callers of g_hook_next_valid().
+
Mon Dec 21 03:48:04 1998 Tim Janik <timj@gtk.org>
* gmain.c (g_main_iterate): default initialize source_timeout with -1
+Mon Dec 21 21:48:29 1998 Tim Janik <timj@gtk.org>
+
+ * glib.h:
+ * gmain.c: there was a reference count race for hooks during invocation
+ loops. since all (known) hook loop implementations, do currently start
+ out with g_hook_first_valid() and iterate with g_hook_next_valid(),
+ g_hook_first_valid() will now return a referenced hook, and
+ g_hook_next_valid() will "eat" that, and eventually transfer it to
+ the next hook. <sigh> unfortunately this requires g_hook_next_valid()
+ to take the hook_list as additional argument.
+
+ * gmain.c (g_main_iterate): adjusted callers of g_hook_next_valid().
+
Mon Dec 21 03:48:04 1998 Tim Janik <timj@gtk.org>
* gmain.c (g_main_iterate): default initialize source_timeout with -1
+Mon Dec 21 21:48:29 1998 Tim Janik <timj@gtk.org>
+
+ * glib.h:
+ * gmain.c: there was a reference count race for hooks during invocation
+ loops. since all (known) hook loop implementations, do currently start
+ out with g_hook_first_valid() and iterate with g_hook_next_valid(),
+ g_hook_first_valid() will now return a referenced hook, and
+ g_hook_next_valid() will "eat" that, and eventually transfer it to
+ the next hook. <sigh> unfortunately this requires g_hook_next_valid()
+ to take the hook_list as additional argument.
+
+ * gmain.c (g_main_iterate): adjusted callers of g_hook_next_valid().
+
Mon Dec 21 03:48:04 1998 Tim Janik <timj@gtk.org>
* gmain.c (g_main_iterate): default initialize source_timeout with -1
+Mon Dec 21 21:48:29 1998 Tim Janik <timj@gtk.org>
+
+ * glib.h:
+ * gmain.c: there was a reference count race for hooks during invocation
+ loops. since all (known) hook loop implementations, do currently start
+ out with g_hook_first_valid() and iterate with g_hook_next_valid(),
+ g_hook_first_valid() will now return a referenced hook, and
+ g_hook_next_valid() will "eat" that, and eventually transfer it to
+ the next hook. <sigh> unfortunately this requires g_hook_next_valid()
+ to take the hook_list as additional argument.
+
+ * gmain.c (g_main_iterate): adjusted callers of g_hook_next_valid().
+
Mon Dec 21 03:48:04 1998 Tim Janik <timj@gtk.org>
* gmain.c (g_main_iterate): default initialize source_timeout with -1
+Mon Dec 21 21:48:29 1998 Tim Janik <timj@gtk.org>
+
+ * glib.h:
+ * gmain.c: there was a reference count race for hooks during invocation
+ loops. since all (known) hook loop implementations, do currently start
+ out with g_hook_first_valid() and iterate with g_hook_next_valid(),
+ g_hook_first_valid() will now return a referenced hook, and
+ g_hook_next_valid() will "eat" that, and eventually transfer it to
+ the next hook. <sigh> unfortunately this requires g_hook_next_valid()
+ to take the hook_list as additional argument.
+
+ * gmain.c (g_main_iterate): adjusted callers of g_hook_next_valid().
+
Mon Dec 21 03:48:04 1998 Tim Janik <timj@gtk.org>
* gmain.c (g_main_iterate): default initialize source_timeout with -1
+Mon Dec 21 21:48:29 1998 Tim Janik <timj@gtk.org>
+
+ * glib.h:
+ * gmain.c: there was a reference count race for hooks during invocation
+ loops. since all (known) hook loop implementations, do currently start
+ out with g_hook_first_valid() and iterate with g_hook_next_valid(),
+ g_hook_first_valid() will now return a referenced hook, and
+ g_hook_next_valid() will "eat" that, and eventually transfer it to
+ the next hook. <sigh> unfortunately this requires g_hook_next_valid()
+ to take the hook_list as additional argument.
+
+ * gmain.c (g_main_iterate): adjusted callers of g_hook_next_valid().
+
Mon Dec 21 03:48:04 1998 Tim Janik <timj@gtk.org>
* gmain.c (g_main_iterate): default initialize source_timeout with -1
+Mon Dec 21 21:48:29 1998 Tim Janik <timj@gtk.org>
+
+ * glib.h:
+ * gmain.c: there was a reference count race for hooks during invocation
+ loops. since all (known) hook loop implementations, do currently start
+ out with g_hook_first_valid() and iterate with g_hook_next_valid(),
+ g_hook_first_valid() will now return a referenced hook, and
+ g_hook_next_valid() will "eat" that, and eventually transfer it to
+ the next hook. <sigh> unfortunately this requires g_hook_next_valid()
+ to take the hook_list as additional argument.
+
+ * gmain.c (g_main_iterate): adjusted callers of g_hook_next_valid().
+
Mon Dec 21 03:48:04 1998 Tim Janik <timj@gtk.org>
* gmain.c (g_main_iterate): default initialize source_timeout with -1
if (!was_in_call)
hook->flags &= ~G_HOOK_FLAG_IN_CALL;
- tmp = g_hook_next_valid (hook, may_recurse);
+ tmp = g_hook_next_valid (hook_list, hook, may_recurse);
g_hook_unref (hook_list, hook);
hook = tmp;
if (need_destroy)
g_hook_destroy_link (hook_list, hook);
- tmp = g_hook_next_valid (hook, may_recurse);
+ tmp = g_hook_next_valid (hook_list, hook, may_recurse);
g_hook_unref (hook_list, hook);
hook = tmp;
if (need_destroy)
g_hook_destroy_link (hook_list, hook);
- tmp = g_hook_next_valid (hook, may_recurse);
+ tmp = g_hook_next_valid (hook_list, hook, may_recurse);
g_hook_unref (hook_list, hook);
hook = tmp;
if (!was_in_call)
hook->flags &= ~G_HOOK_FLAG_IN_CALL;
- tmp = g_hook_next_valid (hook, may_recurse);
+ tmp = g_hook_next_valid (hook_list, hook, may_recurse);
g_hook_unref (hook_list, hook);
hook = tmp;
GHook *hook;
hook = hook_list->hooks;
+ g_hook_ref (hook_list, hook);
if (hook)
{
if (G_HOOK_IS_VALID (hook) && (may_be_in_call || !G_HOOK_IN_CALL (hook)))
return hook;
else
- return g_hook_next_valid (hook, may_be_in_call);
+ return g_hook_next_valid (hook_list, hook, may_be_in_call);
}
}
}
GHook*
-g_hook_next_valid (GHook *hook,
- gboolean may_be_in_call)
+g_hook_next_valid (GHookList *hook_list,
+ GHook *hook,
+ gboolean may_be_in_call)
{
+ GHook *ohook = hook;
+
+ g_return_val_if_fail (hook_list != NULL, NULL);
+
if (!hook)
return NULL;
while (hook)
{
if (G_HOOK_IS_VALID (hook) && (may_be_in_call || !G_HOOK_IN_CALL (hook)))
- return hook;
+ {
+ g_hook_ref (hook_list, hook);
+ g_hook_unref (hook_list, ohook);
+
+ return hook;
+ }
hook = hook->next;
}
-
+ g_hook_unref (hook_list, ohook);
+
return NULL;
}
gboolean need_valids,
gpointer func,
gpointer data);
+/* return the first valid hook, and increment its reference count */
GHook* g_hook_first_valid (GHookList *hook_list,
gboolean may_be_in_call);
-GHook* g_hook_next_valid (GHook *hook,
+/* return the next valid hook with incremented reference count, and
+ * decrement the reference count of the original hook
+ */
+GHook* g_hook_next_valid (GHookList *hook_list,
+ GHook *hook,
gboolean may_be_in_call);
/* GHookCompareFunc implementation to insert hooks sorted by their id */
if (!was_in_call)
hook->flags &= ~G_HOOK_FLAG_IN_CALL;
- tmp = g_hook_next_valid (hook, may_recurse);
+ tmp = g_hook_next_valid (hook_list, hook, may_recurse);
g_hook_unref (hook_list, hook);
hook = tmp;
if (need_destroy)
g_hook_destroy_link (hook_list, hook);
- tmp = g_hook_next_valid (hook, may_recurse);
+ tmp = g_hook_next_valid (hook_list, hook, may_recurse);
g_hook_unref (hook_list, hook);
hook = tmp;
if (need_destroy)
g_hook_destroy_link (hook_list, hook);
- tmp = g_hook_next_valid (hook, may_recurse);
+ tmp = g_hook_next_valid (hook_list, hook, may_recurse);
g_hook_unref (hook_list, hook);
hook = tmp;
if (!was_in_call)
hook->flags &= ~G_HOOK_FLAG_IN_CALL;
- tmp = g_hook_next_valid (hook, may_recurse);
+ tmp = g_hook_next_valid (hook_list, hook, may_recurse);
g_hook_unref (hook_list, hook);
hook = tmp;
GHook *hook;
hook = hook_list->hooks;
+ g_hook_ref (hook_list, hook);
if (hook)
{
if (G_HOOK_IS_VALID (hook) && (may_be_in_call || !G_HOOK_IN_CALL (hook)))
return hook;
else
- return g_hook_next_valid (hook, may_be_in_call);
+ return g_hook_next_valid (hook_list, hook, may_be_in_call);
}
}
}
GHook*
-g_hook_next_valid (GHook *hook,
- gboolean may_be_in_call)
+g_hook_next_valid (GHookList *hook_list,
+ GHook *hook,
+ gboolean may_be_in_call)
{
+ GHook *ohook = hook;
+
+ g_return_val_if_fail (hook_list != NULL, NULL);
+
if (!hook)
return NULL;
while (hook)
{
if (G_HOOK_IS_VALID (hook) && (may_be_in_call || !G_HOOK_IN_CALL (hook)))
- return hook;
+ {
+ g_hook_ref (hook_list, hook);
+ g_hook_unref (hook_list, ohook);
+
+ return hook;
+ }
hook = hook->next;
}
-
+ g_hook_unref (hook_list, ohook);
+
return NULL;
}
gboolean need_valids,
gpointer func,
gpointer data);
+/* return the first valid hook, and increment its reference count */
GHook* g_hook_first_valid (GHookList *hook_list,
gboolean may_be_in_call);
-GHook* g_hook_next_valid (GHook *hook,
+/* return the next valid hook with incremented reference count, and
+ * decrement the reference count of the original hook
+ */
+GHook* g_hook_next_valid (GHookList *hook_list,
+ GHook *hook,
gboolean may_be_in_call);
/* GHookCompareFunc implementation to insert hooks sorted by their id */
break;
if (G_HOOK_IN_CALL (hook) && !(hook->flags & G_SOURCE_CAN_RECURSE))
{
- hook = g_hook_next_valid (hook, TRUE);
+ hook = g_hook_next_valid (&source_list, hook, TRUE);
continue;
}
timeout = MIN (timeout, source_timeout);
}
- tmp = g_hook_next_valid (hook, TRUE);
+ tmp = g_hook_next_valid (&source_list, hook, TRUE);
g_hook_unref (&source_list, hook);
hook = tmp;
break;
if (G_HOOK_IN_CALL (hook) && !(hook->flags & G_SOURCE_CAN_RECURSE))
{
- hook = g_hook_next_valid (hook, TRUE);
+ hook = g_hook_next_valid (&source_list, hook, TRUE);
continue;
}
}
}
- tmp = g_hook_next_valid (hook, TRUE);
+ tmp = g_hook_next_valid (&source_list, hook, TRUE);
g_hook_unref (&source_list, hook);
hook = tmp;
break;
if (G_HOOK_IN_CALL (hook) && !(hook->flags & G_SOURCE_CAN_RECURSE))
{
- hook = g_hook_next_valid (hook, TRUE);
+ hook = g_hook_next_valid (&source_list, hook, TRUE);
continue;
}
timeout = MIN (timeout, source_timeout);
}
- tmp = g_hook_next_valid (hook, TRUE);
+ tmp = g_hook_next_valid (&source_list, hook, TRUE);
g_hook_unref (&source_list, hook);
hook = tmp;
break;
if (G_HOOK_IN_CALL (hook) && !(hook->flags & G_SOURCE_CAN_RECURSE))
{
- hook = g_hook_next_valid (hook, TRUE);
+ hook = g_hook_next_valid (&source_list, hook, TRUE);
continue;
}
}
}
- tmp = g_hook_next_valid (hook, TRUE);
+ tmp = g_hook_next_valid (&source_list, hook, TRUE);
g_hook_unref (&source_list, hook);
hook = tmp;