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 498010 - gtk_tree_view_set_cursor fails if model!=NULL
gtk_tree_view_set_cursor fails if model!=NULL
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkTreeView
2.10.x
Other Linux
: Normal normal
: ---
Assigned To: gtktreeview-bugs
gtktreeview-bugs
Depends on:
Blocks:
 
 
Reported: 2007-11-18 21:41 UTC by Stefan Sauer (gstreamer, gtkdoc dev)
Modified: 2009-07-30 12:03 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Stefan Sauer (gstreamer, gtkdoc dev) 2007-11-18 21:41:47 UTC
gtk_tree_view_set_cursor or gtk_tree_view_real_set_cursor should check for tree_view->priv->model!=NULL. Otherwise:

  • #0 __kernel_vsyscall
  • #1 *__GI_raise
    at ../nptl/sysdeps/unix/sysv/linux/raise.c line 64
  • #2 *__GI_abort
    at abort.c line 88
  • #3 g_logv
    at gmessages.c line 497
  • #4 g_log
    at gmessages.c line 517
  • #5 g_return_if_fail_warning
  • #6 IA__gtk_tree_row_reference_new_proxy
    at gtktreemodel.c line 1943
  • #7 gtk_tree_view_real_set_cursor
    at gtktreeview.c line 12521
  • #8 IA__gtk_tree_view_set_cursor_on_cell
    at gtktreeview.c line 12670
  • #9 IA__gtk_tree_view_set_cursor
    at gtktreeview.c line 12622

Comment 1 Björn Lindqvist 2008-05-20 21:48:52 UTC
I can't reproduce this crash (?). Tried with:

  view = gtk.TreeView()
  view.set_cursor((0, 1, 2))

But I just get the same warning as in your traceback. The traceback also seem to suggest that the crash occurs in gmessages.c and not in gtk. 
Comment 2 Stefan Sauer (gstreamer, gtkdoc dev) 2008-05-21 15:32:43 UTC
Its with fatal warnings. Thats way it terminates. Basically I am complaining about  that gtk_tree_view_set_cursor() should just return if there is no model and not blindly make furtehr calls.
Comment 3 Björn Lindqvist 2008-05-21 20:30:07 UTC
Oh, now I understand. I don't think it should "just return" but instead check "g_return_if_fail (tree_view->priv->model != NULL);" in the beginning of set_cursor() because that is consistent with scroll_to_cell(), expand_row(), collapse_row() and how other methods that expect the model to be there behaves.  
Comment 4 Kristian Rietveld 2008-05-28 12:21:17 UTC
Committed a return if fail ->priv->tree != NULL (if there is no tree, there is no model either) in gtk_tree_view_set_cursor_on_cell) in r20208.
Comment 5 Gian Mario Tagliaretti 2008-08-21 08:01:08 UTC
This now breaks pygtk code like:

>>> import gtk
>>> model = gtk.ListStore(str)
>>> treeview = gtk.TreeView(model)
>>> treeview.set_cursor(1)
__main__:1: GtkWarning: gtk_tree_view_set_cursor_on_cell: assertion `tree_view->priv->tree != NULL' failed
Comment 6 Johan (not receiving bugmail) Dahlin 2008-08-21 11:33:38 UTC
Kris, is the testcase wrong or is the assertion wrong?
Comment 7 Kristian Rietveld 2009-07-30 12:03:18 UTC
The assertion is wrong and I have fixed this.  The function now fails silently again.  I have added the test case from comment 5 to the unit tests as well.  I have also clarified the new semantics in the documentation.

At comment 3: we can look into making the other calls consistent later on -- still need to make up my mind on this.  At least set_cursor() can unset the current cursor if the new given path is invalid, scroll_to_cell(), expand and collapse can't do anything when the input is wrong.