[pygtk] Invalid TreeIter from custom treemodel

John Finlay finlay at moeraki.com
Thu Aug 12 04:42:48 WST 2004


Vitaly Ostanin wrote:

> John Finlay wrote:
>
> <skipped/>
>
>>> Execution of my program output on stderr:
>>> ** (pix.py:11897): CRITICAL **: file pygtktreemodel.c: line 739 
>>> (pygtk_generic_tree_model_ref_node): assertion `VALID_ITER(iter, 
>>> tree_model)' failed
>>>
>>> Please, tell me, how I can get valid custom iters from XML node 
>>> pointer ?
>>>
>>> pygtk-2.3.94
>>> libgtk+2-2.4.4
>>> libxml2-python-2.6.11-alt1
>>> Python 2.3.3
>>>
>> What code is generating the warning message? The above code doesn't 
>> deal with TreeIters.
>
>
> May be :) Full example is attached.
>
Your custom model has a couple of broken methods:

on_iter_n_children() and on_iter_nth_child()

These do not properly handle the case where iter or parent is None. 
These special cases indicate the toplevel rows should be used. See:

file:///usr/local/doc/pygtk2reference/class-gtktreemodel.html#method-gtktreemodel--iter-n-children 
<cid:part1.03000202.03070209 at moeraki.com>
file:///usr/local/doc/pygtk2reference/class-gtktreemodel.html#method-gtktreemodel--iter-nth-child 
<cid:part2.01070303.04070005 at moeraki.com>

for more info. As a guess you should start each with something like:

if not node:
    node = self.doc

John




More information about the pygtk mailing list