GNOME Bugzilla – Bug 659672
gtk_tree_view_column_dispose() does not remove from tree view
Last modified: 2012-01-12 22:02:24 UTC
gtk_widget_dispose() removes the widget from a container, if it belongs to one: if (priv->parent) gtk_container_remove (GTK_CONTAINER (priv->parent), widget); But gtk_tree_view_column_dispose() does not remove the tree view column from the tree view it belongs to. This lack of removal may give rise to a series of critical messages, at least in the C++ binding, gtkmm. Steps to reproduce: I have no C program to demonstrate this behaviour. I noticed it in the C++ program http://git.gnome.org/browse/gtkmm-documentation/tree/examples/book/treeview/editable_cells Perhaps this is a problem only in language bindings. Actual results: When the program's window is closed, the following is printed: (example:3094): GLib-GObject-WARNING **: invalid (NULL) pointer instance (example:3094): GLib-GObject-CRITICAL **: g_signal_handler_block: assertion `G_TYPE_CHECK_INSTANCE (instance)' failed (example:3094): Gtk-CRITICAL **: gtk_cell_area_context_reset: assertion `GTK_IS_CELL_AREA_CONTEXT (context)' failed (example:3094): GLib-GObject-WARNING **: invalid (NULL) pointer instance (example:3094): GLib-GObject-CRITICAL **: g_signal_handler_unblock: assertion `G_TYPE_CHECK_INSTANCE (instance)' failed (example:3094): Gtk-CRITICAL **: gtk_cell_area_context_get_preferred_width: assertion `GTK_IS_CELL_AREA_CONTEXT (context)' failed (example:3094): Gtk-CRITICAL **: gtk_cell_area_apply_attributes: assertion `GTK_IS_CELL_AREA (area)' failed ... and more of the same sort. Expected results: No messages. Build date and platform: Ubuntu 11.04, source code of gtk+, etc. from git's master branch, built with jhbuild on 2011-09-19. Additional information: The C++ wrapper Gtk::TreeView and one Gtk::TreeViewColumn are allocated in such a way that the Gtk::TreeViewColumn will be deleted before the Gtk::TreeView. Then the Gtk::TreeViewColumn calls g_object_run_dispose() to dispose of the wrapped GtkTreeViewColumn object. The GtkTreeView is not told that one of its columns is disposed of. That causes problems when the GtkTreeView is deleted. The following code near the beginning of gtk_tree_view_column_dispose() would fix the bug: if (priv->tree_view) gtk_tree_view_remove_column(GTK_TREE_VIEW (priv->tree_view), tree_column); It would be possible to add equivalent code to Gtk::TreeViewColumn's destructor, but perhaps this bug exists also in other language bindings. Then it would be better to solve it in GTK+.
I guess we need a C test case.
> I noticed it in the C++ > program > http://git.gnome.org/browse/gtkmm-documentation/tree/examples/book/treeview/editable_cells I tried running that. I don't see the warnings. I'm using GTK+ from git master.
Actually, sorry, yes, I do. I had your fix in gtk+ already, hoping that it would solve a similar problem (it didn't).
Created attachment 197650 [details] [review] 0001-GtkTreeViewColumn-dispose-Remove-from-the-treeview.patch Here is your change as a git patch (with you as the author). I notice that GtkTreeView does this in a destroy handler, while this change is in GtkTreeViewColumn's dispose handler. As far as I know, dispose is the right place to do this, but I do wonder about it.
Created attachment 198027 [details] C test case Here is a C test case at last. It's a modified version of gtk+/tests/testtreeedit.c. I should warn C programmers that this program looks contrived and unnatural. To get the warnings and critical messages that the C++ program generates, I had to simulate parts of what the C++ wrapper classes do. The similation is not correct in all detail, but it's good enough here. And, yes, the patch in comment 4 fixes the bug.
Was fixed in master branch 2011-10-06 http://git.gnome.org/browse/gtk+/commit/?id=f920ded54116f44c9f269d2e509d108a85e943b0
Oops. I don't think I meant to push that. But it was a while ago, so I guess it has had some testing. I'll revert it if asked to.