gtk-2 bug, inconsistency or simply misunderstanding on my side ?

Olivier Fourdan fourdan at xfce.org
Thu Sep 26 23:21:03 CEST 2002


Hi all,

I've seem some behaviour in gkt that I don't understand well.

The problem shows like this :

create a container (a frame)
add another container (another frame) inside the first one.
at last, add a widget to the last container.

It looks like this :

container1
    +-> container2
             +->widget

It happens that, when destroying container2 the widget is freed twice
(even if the widget is *not* destroyed explicitely by the program).

This is because (if I understand well) when destroying the container,
the widget is removed from the container first, so its reference count
is decremented and reach zero, so it gets automatically free, and then
the widget is freed again because its parent is destroyed.

The (easy to tell, hard to find) workarround is to force a
g_object_ref() on the widget at creation. This way, the
gtk_container_remove performed automatically doesn't free the widget, so
it gets freed only once.

Do all this make any sense ? Am I missing something obvious here ?

Thanks in advance,

Best regards,
-- 
Olivier               <fourdan at xfce.org>            http://www.xfce.org
-----------------------------------------------------------------------
XFce is a lightweight  desktop  environment  for  various *NIX systems. 
Designed for productivity,  it loads  and  executes  applications fast,
while conserving  system resources. XFce is all free software, released
under GNU General Public License.    Available from http://www.xfce.org




More information about the Xfce4-dev mailing list