I think I may have found the problem with the gtk.TreeModelSort. The
error message that was returned by pygtk indicated that a NULL iter was
the problem. However, NULL is a valid argument that the function can
receive.

The attached patch removes the check for a NULL iter, and makes sure
that if a NULL iter is received, the PyObject_CallMethod is called with
Py_None.

It also requires that the treemodel.py's on_iter_n_children task be
modified to accept None as the iter, and return the self.TREE_DEPTH when
None is accepted.

    def on_iter_n_children(self, node):
        '''returns the number of children of this node'''
        if node == None:
            return self.TREE_DEPTH
        if len(node) < self.TREE_DEPTH:
            return self.TREE_SIBLINGS
        else:
            return 0


-- 
Don Allingham <[EMAIL PROTECTED]>
GRAMPS OpenSource Genealogy
diff -rup src/pygtk-2.0.0/gtk/pygtktreemodel.c /usr/local/src/pygtk-2.0.0/gtk/pygtktreemodel.c
--- src/pygtk-2.0.0/gtk/pygtktreemodel.c	2003-06-30 07:40:21.000000000 -0600
+++ /usr/local/src/pygtk-2.0.0/gtk/pygtktreemodel.c	2003-10-25 21:20:04.000000000 -0600
@@ -532,7 +532,6 @@ pygtk_generic_tree_model_iter_n_children
 
     g_return_val_if_fail(tree_model != NULL, FALSE);
     g_return_val_if_fail(PYGTK_IS_GENERIC_TREE_MODEL(tree_model), FALSE);
-    g_return_val_if_fail(iter != NULL, FALSE);
 
     pyg_block_threads();
 
@@ -542,8 +541,14 @@ pygtk_generic_tree_model_iter_n_children
 #ifdef DEBUG_TREE_MODEL
     g_message("iter_n_children(%p)", iter);
 #endif
-    py_ret = PyObject_CallMethod(self, METHOD_PREFIX "iter_n_children",
-				 "(O)", (PyObject *)iter->user_data);
+    if (iter == NULL) {
+	py_ret = PyObject_CallMethod(self, METHOD_PREFIX "iter_n_children",
+				     "(O)", Py_None);
+    } else {
+	py_ret = PyObject_CallMethod(self, METHOD_PREFIX "iter_n_children",
+				     "(O)", (PyObject *)iter->user_data);
+    }
+
     if (py_ret) {
 	gint ret = PyInt_AsLong(py_ret);
 

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to