[PyQt] Re: seeking advice on why this script segfaults

Darren Dale dsdale24 at gmail.com
Thu Mar 12 16:31:40 GMT 2009


On Wed, Mar 11, 2009 at 11:56 AM, Darren Dale <dsdale24 at gmail.com> wrote:

> On Tue, Mar 10, 2009 at 8:03 PM, Darren Dale <dsdale24 at gmail.com> wrote:
>
>> On Tue, Mar 10, 2009 at 5:28 PM, Darren Dale <dsdale24 at gmail.com> wrote:
>>
>>> Hello,
>>>
>>> I am trying to create a simple model and view for a simple nested
>>> dictionary like d:
>>>
>>>     c1 = {'id':1, 'description':'child 1'}
>>>     c2 = {'id':2, 'description':'child 2'}
>>>     d = {'id':0, 'description':'whatever', 'children':[c1, c2]}
>>>
>>> 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:
>>>
>>> Traceback (most recent call last):
>>>   File "tree_test.py", line 111, in parent
>>>     parent = index.internalPointer().parent
>>> AttributeError: 'ItemDataRole' object has no attribute 'parent'
>>> Traceback (most recent call last):
>>>   File "tree_test.py", line 111, in parent
>>>     parent = index.internalPointer().parent
>>> AttributeError: parent
>>>
>>> Traceback (most recent call last):
>>>   File "tree_test.py", line 111, in parent
>>>     parent = index.internalPointer().parent
>>> AttributeError: 'exceptions.AttributeError' object has no attribute
>>> 'parent'
>>> Bus error
>>>
>>> sometimes I get a different error:
>>>
>>> Traceback (most recent call last):
>>>   File "tree_test.py", line 111, in parent
>>>     parent = index.internalPointer().parent
>>> AttributeError: 'ItemDataRole' object has no attribute 'parent'
>>> Segmentation fault
>>>
>>>
>>> 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.
>>>
>>> Im running Qt-4.5.0, sip-4.7.9 and PyQt-4.4.4.
>>
>>
>> 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.
>>
>
> 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.
>
> Please, can anyone suggest why this causes a crash?
>

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.

Thank you,
Darren
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20090312/79ec2077/attachment.html


More information about the PyQt mailing list