gtk_container_remove() and pack later again



Hello,

I have some strange effects: Nearly all displayed text in
widgets (labels, buttons etc) is *sometimes* suddenly
replaced by squares. I suspect the bug is somewhere around
gtk_container_remove().

So, could anyone please confirm if this is correctly coded:



(1) To remove a child for possible later usage I do:

g_object_ref(G_OBJECT(child)); 

gtk_container_remove(
  GTK_CONTAINER(container),GTK_WIDGET(child));

/* it is unclear at coding time if the wiget will ever
 * be needed again or not, so: */
g_object_force_floating(child));



(2) To later re-pack the child

/* I hope this does internally g_object_ref_SINK() ...: */
gtk_box_pack_start/end(
  GTK_BOX(container), child, ...);



(3) Before the child is destroyed (app closed) I do: */

...

if( g_object_is_floating( G_OBJECT(child) ))
{

  g_object_ref_sink( G_OBJECT(child) );

  g_object_unref( G_OBJECT(child) );

}

...


I use the following versions on win32:

atk=1.26.0-1
cairo=1.8.8-2
expat=2.0.1-1
freetype=2.3.9-1
gettext=0.17-1
glib=2.20.5-1
glib_dir=2.20
gtk=2.16.6-1
jpeg=7-1
fontconfig=2.7.3-1
libpng=1.2.39-1
libtiff=3.9.1-1
pango=1.24.5-2
zlib=123

Any help welcome...

 Felix





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