Destroying widgets properly



Hello,
I am getting mysterious and inconsistent crashes in my gtk program
(ie it isn't crashing in the same spot every time), and
I believe it has something to do with how I am destroying a set of
widgets.  I have an hbox (HB) packed into a vbox (VB).  HB has many
widgets packed inside of it, most of which are also created/maintained
in their own C++ classes.  One of the widgets is a GnomeCanvas, and it
itself has many GnomeCanvasItem children, nearly each maintained in
seperate C++ classes as well.  At times, I need to entirely remove HB
and all of it's children including the canvas and all of it's children.
I then recreate everything from scratch and pack into VB.  Actually the
destroy seems to work OK.  It is when I try to recreate all the widgets
that I get the core dump.

I tried having each class destructor first delete it's children (with a
'delete'), then destroy it's own widget (in the case of the
GnomeCanvasItems, using GTK_OBJECT_DESTROY and casting the CanvasItem).
I thought this made the most sense since you want to delete the children
first before you delete the parent or you'll have children pointing to
parents that no longer exist.  I also tried reversing the order as well
but get the same result.  I get error messages like this:

GLib-GObject-WARNING **: invalid uninstantiatable type
`gint64' in cast to `GtkObject'

Gtk-CRITICAL **: file gtkobject.c: line 358
(gtk_object_destroy): assertion `GTK_IS_OBJECT (object)' failed

GLib-GObject-WARNING **: invalid cast from `(null)' to
`GtkObject'

Gtk-CRITICAL **: file gtkobject.c: line 358
(gtk_object_destroy): assertion `GTK_IS_OBJECT (object)' failed


I tried just doing a destroy on HB but get the same results.  It seems
like I'm leaving something behind.  It works a few times, then crashes.
Or it crashes on the first try. 

Thanks for any help
Jason



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