Re: [gtk-list] warning or crash when removing widgets from box



//In an application I'm writing using Gtk+ (Gtk+ 1.0.4, currently)
//I have a GtkVBox that is to contain zero or more GtkToggleButtons,
//which are added and removed from the box according to other user-interface
//operations.
//
//To remove a button, I simply destroy it:
//	gtk_widget_destroy(vw->button);

Try gtk_container_remove( GTK_CONTAINER( my_vbox ), vw->button ); instead. This 
removes it from the vbox, which will cause the vbox to unref it, which will 
(probably) cause the reference count to reach zero -> destroyed.

//My understanding is that gdk_widget_destroy detaches the button from its
//parent container, and then cleans it up.  I thought the above was right,
//based on an older posting to the gtk-list. 

Erm, no. It causes it to be destroyed. Nothing more. So the vbox will still have a reference to it, which probably causes the plethora of warnings and the eventual crash. (And then there is the fact that widgets (like all objects) are reference counted, so you probably meant to say gtk_widget_unref. But that's a different story. Read docs/refcounting.txt if you're interested.)

Good luck.

Johannes.
--
Life is what happens to you while you are making other plans.

Bibliovorous chocophiliac.




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