After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 659672 - gtk_tree_view_column_dispose() does not remove from tree view
gtk_tree_view_column_dispose() does not remove from tree view
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkTreeView
3.1.x
Other Linux
: Normal normal
: ---
Assigned To: gtktreeview-bugs
gtktreeview-bugs
Depends on:
Blocks:
 
 
Reported: 2011-09-21 08:32 UTC by Kjell Ahlstedt
Modified: 2012-01-12 22:02 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
0001-GtkTreeViewColumn-dispose-Remove-from-the-treeview.patch (1.12 KB, patch)
2011-09-28 11:04 UTC, Murray Cumming
none Details | Review
C test case (14.42 KB, text/plain)
2011-10-02 16:19 UTC, Kjell Ahlstedt
  Details

Description Kjell Ahlstedt 2011-09-21 08:32:15 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+.
Comment 1 Murray Cumming 2011-09-27 08:49:08 UTC
I guess we need a C test case.
Comment 2 Murray Cumming 2011-09-28 10:56:08 UTC
> 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.
Comment 3 Murray Cumming 2011-09-28 10:58:39 UTC
Actually, sorry, yes, I do. I had your fix in gtk+ already, hoping that it would solve a similar problem (it didn't).
Comment 4 Murray Cumming 2011-09-28 11:04:39 UTC
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.
Comment 5 Kjell Ahlstedt 2011-10-02 16:19:23 UTC
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.
Comment 6 Kjell Ahlstedt 2012-01-12 10:17:44 UTC
Was fixed in master branch 2011-10-06
http://git.gnome.org/browse/gtk+/commit/?id=f920ded54116f44c9f269d2e509d108a85e943b0
Comment 7 Murray Cumming 2012-01-12 22:02:24 UTC
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.