<div class="gmail_quote">On Wed, Mar 11, 2009 at 11:56 AM, Darren Dale <span dir="ltr"><<a href="mailto:dsdale24@gmail.com">dsdale24@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="gmail_quote"><div><div></div><div class="h5">On Tue, Mar 10, 2009 at 8:03 PM, Darren Dale <span dir="ltr"><<a href="mailto:dsdale24@gmail.com" target="_blank">dsdale24@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="gmail_quote"><div><div></div><div>On Tue, Mar 10, 2009 at 5:28 PM, Darren Dale <span dir="ltr"><<a href="mailto:dsdale24@gmail.com" target="_blank">dsdale24@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello,<br><br>I am trying to create a simple model and view for a simple nested dictionary like d:<br><br> c1 = {'id':1, 'description':'child 1'}<br> c2 = {'id':2, 'description':'child 2'}<br>
d = {'id':0, 'description':'whatever', 'children':[c1, c2]}<br><br>I have a self-contained, relatively simple script attached. When I run it and try to open the top-level entry by clicking on the +, I get errors like:<br>
<br>Traceback (most recent call last):<br> File "tree_test.py", line 111, in parent<br> parent = index.internalPointer().parent<br>AttributeError: 'ItemDataRole' object has no attribute 'parent'<br>
Traceback (most recent call last):<br> File "tree_test.py", line 111, in parent<br> parent = index.internalPointer().parent<br>AttributeError: parent<br><br>Traceback (most recent call last):<br> File "tree_test.py", line 111, in parent<br>
parent = index.internalPointer().parent<br>AttributeError: 'exceptions.AttributeError' object has no attribute 'parent'<br>Bus error<br><br>sometimes I get a different error:<br><br>Traceback (most recent call last):<br>
File "tree_test.py", line 111, in parent<br> parent = index.internalPointer().parent<br>AttributeError: 'ItemDataRole' object has no attribute 'parent'<br>Segmentation fault<br><br><br>Could anyone please help me understand what is happening? I dont understand why index.internalPointer() is returning an ItemDataRole object or an exceptions.AttributeError object.<br>
<br>Im running Qt-4.5.0, sip-4.7.9 and PyQt-4.4.4.<font color="#888888"></font></blockquote></div></div><div><br>I just checked this script on a 64-bit kubuntu intrepid system with qt-4.4.3 and PyQt4-4.4.4, sip-4.7.9 and python-2.5.2 and I get segfaults here too. I guess that rules out some issue specific to qt-4.5.<br>
</div></div></blockquote></div></div><div><br>I've been looking into this some more, and I managed to isolate the problem. The attached script runs ok when CACHE_CHILDREN = True, but it will yield bus errors or segfaults when CACHE_CHILDREN is False. Unfortunately, I am modeling an object that can be changed elsewhere in the application, so it is imperitive that I am able to recalculate the child list. I have done the exact same thing using Enthought's Traits package with the Traits Qt4 backend, and never saw segfaults, so I know it must be possible.<br>
<br>Please, can anyone suggest why this causes a crash?<br></div></div></blockquote><div><br>If anybody has some example of a working QAbstractItemModel/QTreeView for dynamic data, would you please consider posting it (if its short) or sending it to me off list? I've been working on this problem for days now and I'm not getting anywhere.<br>
<br>Thank you,<br>Darren <br></div></div>