mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-11-12 13:52:55 +01:00
GMainContext: unref pending sources on destroy
It is possible (but unlikely) that there will be a non-empty list of pending dispatches when we remove the last ref from a GMainContext. Make sure we drop the refs on the sources appropriately. Add a (now-working) testcase that demonstrates how to trigger the issue. https://bugzilla.gnome.org/show_bug.cgi?id=139699
This commit is contained in:
committed by
Matthias Clasen
parent
2a3ee7ceaf
commit
8f6be404cb
@@ -507,6 +507,7 @@ g_main_context_unref (GMainContext *context)
|
||||
GSource *source;
|
||||
GList *sl_iter;
|
||||
GSourceList *list;
|
||||
gint i;
|
||||
|
||||
g_return_if_fail (context != NULL);
|
||||
g_return_if_fail (g_atomic_int_get (&context->ref_count) > 0);
|
||||
@@ -518,6 +519,10 @@ g_main_context_unref (GMainContext *context)
|
||||
main_context_list = g_slist_remove (main_context_list, context);
|
||||
G_UNLOCK (main_context_list);
|
||||
|
||||
/* Free pending dispatches */
|
||||
for (i = 0; i < context->pending_dispatches->len; i++)
|
||||
g_source_unref_internal (context->pending_dispatches->pdata[i], context, FALSE);
|
||||
|
||||
/* g_source_iter_next() assumes the context is locked. */
|
||||
LOCK_CONTEXT (context);
|
||||
g_source_iter_init (&iter, context, TRUE);
|
||||
|
||||
Reference in New Issue
Block a user