This avoids ugly deadlock situations such as in
https://bugzilla.gnome.org/show_bug.cgi?id=586432
https://bugzilla.gnome.org/show_bug.cgi?id=626702
https://bugzilla.gnome.org/show_bug.cgi?id=634239
g_source_list_remove (source, context);
if (source->source_funcs->finalize)
- source->source_funcs->finalize (source);
+ {
+ if (context)
+ UNLOCK_CONTEXT (context);
+ source->source_funcs->finalize (source);
+ if (context)
+ LOCK_CONTEXT (context);
+ }
g_free (source->name);
source->name = NULL;