Re: qdata callback not called



On Thu, 2003-06-26 at 02:54, Murray Cumming Comneon com wrote:
> I believe that the callback given to g_object_set_qdata_full()
> should be called when the GObject is destroyed, but it doesn't seem to work
> in this simple test case:
> http://bugzilla.gnome.org/showattachment.cgi?attach_id=17788
> 
> Have I made a simple mistake in that test code, or am I misunderstanding
> something?
> 
> We use this in the internals of gtkmm and I'm sure it works most of the
> time, so I am confused. We can of course just connect to the "destroy"
> signal if we can't get this to work consistently.

qdata is freed on finalize, not on destroy. Your example leaks
the button, so the qdata will never be freed.

The reason that it leaks is probably most apparent if you 
understand why it is *not* leaked in the normal case:

 create button: reference count 1, floating
 add button to container: container adopts button, reference count 1,
  not floating
 destroy button: button is removed from parent, reference
  count drops to 0, finalized

But if you destroy a floating button, nothing will happen to
the reference count.

Regards,
						Owen





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]