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



Olivier Fourdan <fourdan xfce org> writes:

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 ?

How are you removing it? What do you mean by "freed twice"?
Can you provide a small test case?

Two signal emissions of ::destroy is legitimate and will happen
under some circumstances, but is usually not visible to apps
because signals handler are removed when ::destroy is 
emitted.

Regards,
                                        Owen



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