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 125172 - gtk.TreeModelSort returns an unusable object
gtk.TreeModelSort returns an unusable object
Status: RESOLVED FIXED
Product: pygtk
Classification: Bindings
Component: general
1.99.x/2.0.x
Other Linux
: High normal
: ---
Assigned To: Python bindings maintainers
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2003-10-22 02:35 UTC by dallingham
Modified: 2005-08-22 12:44 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Modified treemodel.py file that exhibits the problem (3.62 KB, text/plain)
2003-10-22 02:36 UTC, dallingham
  Details
Patch to possibly fix the TreeModelSort problem (1.08 KB, patch)
2003-10-26 03:36 UTC, dallingham
none Details | Review
Updated patch to fix TreeModelSort problem (394 bytes, patch)
2004-01-02 16:22 UTC, dallingham
none Details | Review

Description dallingham 2003-10-22 02:35:09 UTC
Using gtk.TreeModelSort(model) seems to return a model that cannot be used.
Attempting to set a TreeView's model with the object issues the following
errors:

** (treemodel.py:1363): CRITICAL **: file pygtktreemodel.c: line 535
(pygtk_generic_tree_model_iter_n_children): assertion `iter != NULL' failed
 
(treemodel.py:1363): Gtk-CRITICAL **: file gtktreemodelsort.c: line 2172
(gtk_tree_model_sort_build_level): assertion `length > 0' failed

As a testcase, I took the treemodel.py demo file from the pygtk
distribution, and modified it from:

model = MyTreeModel()
tree_view = gtk.TreeView(model)

To:

model = MyTreeModel()
sort_model = gtk.TreeModelSort(mode)
tree_view = gtk.TreeView(sort_model)

I have tried this with several other models, all with similar results.
Comment 1 dallingham 2003-10-22 02:36:36 UTC
Created attachment 20856 [details]
Modified treemodel.py file that exhibits the problem
Comment 2 dallingham 2003-10-26 03:36:14 UTC
Created attachment 20946 [details] [review]
Patch to possibly fix the TreeModelSort problem
Comment 3 Gustavo Carneiro 2003-10-26 14:47:50 UTC
  This patch looks good.  NULL is indeed a valid value for iter,
looking at the gtk+ comment (gtk+/gtk/gtktreemodel.c):

 * gtk_tree_model_iter_n_children:
 * @tree_model: A #GtkTreeModel.
 * @iter: The #GtkTreeIter, or %NULL.
 *
 * Returns the number of children that @iter has.  As a special case,
if @iter
 * is %NULL, then the number of toplevel nodes is returned.
 *
 * Return value: The number of children of @iter.

  NULL as synonym of the model root is used all over the place in
GtkTreeModel.  Moreover, NULL mapping to python None is usual practice.
Comment 4 Johan (not receiving bugmail) Dahlin 2003-12-18 22:52:45 UTC

*** This bug has been marked as a duplicate of 126479 ***
Comment 5 dallingham 2004-01-02 16:22:05 UTC
Created attachment 22841 [details] [review]
Updated patch to fix TreeModelSort problem
Comment 6 dallingham 2004-01-02 16:26:24 UTC
This was marked as a duplicate of 126479. While the patch for 126479
resolves many of the problems associated with the report, it does not
resolve all of them. The testcase originally supplied still does not
work. When a new model is returned by TreeModelSort, the TreeModelSort
will call pygtk_generic_tree_model_iter_n_children with the iter
argument set to NULL, which causes all kinds of problems.

The new patch attached should resolve this problem.
Comment 7 Johan (not receiving bugmail) Dahlin 2004-01-14 15:28:03 UTC
Okay, sorry missed that one.
Should be fixed in CVS now.

Thanks