ext/glib2/rbgobj_closure.c in glib2-4.0.8 vs ext/glib2/rbgobj_closure.c in glib2-4.0.9

- old
+ new

@@ -156,11 +156,11 @@ } static void rclosure_weak_notify(gpointer data, GObject* where_the_object_was); static void -rclosure_finalize(G_GNUC_UNUSED gpointer data, GClosure *closure) +rclosure_invalidate(G_GNUC_UNUSED gpointer data, GClosure *closure) { GRClosure *rclosure = (GRClosure *)closure; GList *next; for (next = rclosure->objects; next; next = next->next) { @@ -198,11 +198,16 @@ GRClosure *rclosure = data; if (!rclosure) return; - g_closure_unref((GClosure *)rclosure); + GClosure *closure = (GClosure *)rclosure; + gboolean last_reference = (closure->ref_count == 1); + g_closure_unref(closure); + if (!last_reference) { + g_closure_invalidate(closure); + } } static const rb_data_type_t rbg_closure_holder_type = { "GLib::ClosureHolder", { @@ -235,10 +240,10 @@ rclosure->tag[0] = '\0'; g_closure_ref(closure); g_closure_sink(closure); g_closure_set_marshal(closure, &rclosure_marshal); - g_closure_add_finalize_notifier(closure, NULL, rclosure_finalize); + g_closure_add_invalidate_notifier(closure, NULL, rclosure_invalidate); return closure; } GClosure *