Re: stupid question



Federico Mena Quintero <federico@helixcode.com> writes:

> >  > I wellcome any answer because this _really_ makes me feel stupid.
> >  > I don't understand. What unrefs our GtkObjects ? after the destruction ?
> >  
> >  Typically you want to "gtk_objet_destroy" top-level windows, as Gtk+
> >  will keep its own reference to them from somewhere.
> >  
> >  For anything else, we must use the _unref versions of those.
> 
> Not quite.
> 
> Widgets are a special case of objects for a couple of reasons:
> 
> 	1. You normally don't own their base reference, as their
>            parent container owns it.
> 
> 	2. Widgets are a kind of objects that you *do* want to be
>            unconditionally destroyed at arbitrary times, instead of
>            waiting for every interested party to unref() it.
> 
> (2) is important because sometimes you do want something like a button
> to just disappear, instead of waiting for everyone to unref() it.
> 
> So most of the time you either gtk_container_remove() a widget and it
> will magically die if there are no other refcounts to it, or you will
> gtk_widget_destroy() a widget and it will go away.
> 
> For normal objects, you should gtk_object_unref() them.

However, if you are using Bonobo controls in a more complicated way,
other parts of your programs may still hold refs to the underlying
bonobo control even when you no longer want it's associated widget in
your hierarchy, so you really ought to container_remove() it and then
unref () it. But this is broken right now due to the circular
reference issue I mentioned earlier (proosed patch coming as soon as I
have time to fix it).

 - Maciej




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