Re: gtk_object_sink in glade_palette_init



Thanks for shedding some light on this piece of code. There's some more light at the end of my dark GTK-knowledge tunnel.

AFAIU, after the _new() the box has a special reference to it: the ref
count is one, but it is marked as "floating"[1]. Now gtk_object_sink()
decrements the ref coung by one *only* if the object is marked as
floating and does nothing otherwise. So the net effect of this code is
to clear the floating flag. See for example

 <http://developer.gnome.org/doc/GGAD/z57.html>

for an explanation.

- ------------
[1] What this means in terms of practical consequences isn't quite clear
to me (perhaps some guru cares to give a pointer), but the idea is to
keep a ref to an yet-unused object you don't want to disappear from
under you before you've put it safely somewhere. Think of it as "half
referenced".

Note that putting the object in a container or whatever sinks() it and
that leads to quite natural code without ref leaks.



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