diff options
author | Giovanni Campagna <gcampagna@src.gnome.org> | 2013-01-03 22:53:06 +0100 |
---|---|---|
committer | Giovanni Campagna <gcampagna@src.gnome.org> | 2013-01-20 16:23:32 +0100 |
commit | 1ce415b45bde895c31dd32e2f7ab7e7ab79e735e (patch) | |
tree | 3912dfae3b14b3eceb8db881ea615f9feaac7d1f | |
parent | e68402e330b977fb6324af6eca7ccf612b0e8b9c (diff) |
Install an invalidation notifier for GClosure in g_source_set_closure()
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
-rw-r--r-- | gobject/gsourceclosure.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/gobject/gsourceclosure.c b/gobject/gsourceclosure.c index 644a1e028..16f34ee6c 100644 --- a/gobject/gsourceclosure.c +++ b/gobject/gsourceclosure.c @@ -145,6 +145,13 @@ static GSourceCallbackFuncs closure_callback_funcs = { closure_callback_get }; +static void +closure_invalidated (gpointer user_data, + GClosure *closure) +{ + g_source_destroy (user_data); +} + /** * g_source_set_closure: * @source: the source @@ -176,6 +183,8 @@ g_source_set_closure (GSource *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; |