[gsignal] disconnect invalidated closures
authorMatthias Clasen <maclas@gmx.de>
Wed, 23 Jun 2004 05:49:24 +0000 (01:49 -0400)
committerRyan Lortie <desrt@desrt.ca>
Mon, 8 Oct 2012 15:21:48 +0000 (11:21 -0400)
commitd03d26feabc5861fe43d503f5e06d73cee9c6fe8
tree3fb32550108085a8ff0a4cbb3e9ab3fbb68647dc
parentd9730f0e319472750f5b7b8b62743ded86e5eaeb
[gsignal] disconnect invalidated closures

Modify gsignal to automatically disconnect a GClosure that becomes
invalid (in the g_closure_invalidate() sense).

Previously, when g_signal_connect_object() was used with a GObject as
the user_data and that object was destroyed, the handler would no longer
be called but the signal handler was itself was not disconnected (ie:
the bookkeeping data was kept around).

The main effect of this patch is that these signal handlers will now
be automatically disconnected (and fully freed).

The documentation for g_signal_connect_object() has anticipated this
change for over 10 years and has advised the following workaround when
disconnecting signal handlers connected with g_signal_connect_object():

 if (g_signal_handler_is_connected (instance, id))
   g_signal_handler_disconnect (instance, id);

If your code follows this practice then it will continue to work.

If your code never disconnects the signal handler then it was wasting
memory before (and this commit fixes that).

If your code unconditionally disconnects the signal handler then you
will start to see (harmless) g_critical() warnings about this and you
should fix them.

https://bugzilla.gnome.org/show_bug.cgi?id=118536
gobject/gsignal.c