GNOME Bugzilla – Bug 658200
gtk_toolbar_finalize() does stuff it shouldn't
Last modified: 2011-09-05 15:09:43 UTC
gtk_toolbar_finalize() has code to remove and destroy all its internal and external children. The external children don't matter since gtk_container_destroy() has already removed them, but the internal child removals: if (priv->arrow_button) gtk_widget_unparent (priv->arrow_button); and: if (priv->menu) { g_signal_handlers_disconnect_by_func (priv->menu, menu_deactivated, toolbar); gtk_widget_destroy (GTK_WIDGET (priv->menu)); } cause problems because finalize because they will cause ::parent-set to be emitted on the children, with the toolbar as an old_parent argument. And once you are in finalize with a refcount of zero, you can't use an object as a signal parameter. *Mostly* this ends up not mattering since we short-circuit the ::parent-set if there are no signal handlers on the child, but if you have an overridden class closure or emission hook, you get a warning: GLib-GObject-CRITICAL **: g_object_ref: assertion `object->ref_count > 0' failed Will attach a program that demonstrates. The fix is to move the widget manipulation that's in gtk_toolbar_finalize() to a gtk_toolbar_dispose() (will need a little added safety against being run multiple times, such as nulling out priv->arrow-button.)
Created attachment 195640 [details] Test case for reproducing bug
(Should note that this was originally from bug 642527)
The following fix has been pushed: 5445b3d GtkToolbar: Move child removal to dispose
Created attachment 195707 [details] [review] GtkToolbar: Move child removal to dispose Doing it in finalize is too late and can cause various problems in ::parent-set signal handlers.