GNOME Bugzilla – Bug 92185
GnomeMDI Crashes
Last modified: 2004-12-22 21:47:04 UTC
Hi, I know the GnomeMDI framework is deprecated in Gnome 2.0 but I really like the simplicity of the interface so I decided to work on it. But when destroying the GnomeMDI (GtkObject) the program always crashes. Also, when removing children, there is a warning about removing a floating reference. I tracked down the problem and found a solution. Since GnomeMDI is a GtkObject descendant it has a floating reference when it is created and it does not get removed since it has never been added in a container widget. If you call g_object_unref on it there will be complications. In order to remove the floating reference (and finalize the object) the following changes may help: gnome-mdi.c AROUND LINE 252 REMOVE: // if (G_OBJECT (object)->ref_count > 0) // g_object_unref(object); ADD: gtk_object_sink (GTK_OBJECT(object)); AROUND LINE 1466 REMOVE: // g_object_unref(G_OBJECT(child)); ADD: gtk_object_sink(GTK_OBJECT(child)); After those changes the crashes disappear and all finalizations are done.
Jaka, could you take a look at the suggested fix here please?
well, the Right Way(tm) to do this would be to make GnomeMDI in GnomeMDIChild descendants of GObject instead of GtkObject. but since the MDI API is deprecated, I won't bother. the patch however serves its purpose: finalizations are done and the thing doesn't crash. I applied it to libgnomeui: HEAD, gnome-2-2 and gnome-2-0 branches.