The point of g_source_set_closure() is getting memory management right,
including handling closures disappearing from the outside (for example
because a runtime they refer to is being shutdown). This means that
sources with an associated closure should remove themselves from the
main loop and free memory when the closure is invalidated.
https://bugzilla.gnome.org/show_bug.cgi?id=692034
closure_callback_get
};
+static void
+closure_invalidated (gpointer user_data,
+ GClosure *closure)
+{
+ g_source_destroy (user_data);
+}
+
/**
* g_source_set_closure:
* @source: the source
g_closure_sink (closure);
g_source_set_callback_indirect (source, closure, &closure_callback_funcs);
+ g_closure_add_invalidate_notifier (closure, source, closure_invalidated);
+
if (G_CLOSURE_NEEDS_MARSHAL (closure))
{
GClosureMarshal marshal = (GClosureMarshal)source->source_funcs->closure_marshal;