[PyQt] PyQt createIndex question

Doug Nichols doug16 at gmail.com
Sun Sep 14 04:23:42 BST 2008

Does the QAbstractModelIndex.createIndex() function increment the reference
count for python objects passed into the internal pointer parameter?  It
appears that it does not.  If it does not, is it supposed to?  I'm trying to
implement a tree model for data contained in a MySQL database.  The data can
change in the background at any time and children of root elements can and
frequently are children of multiple root items.  This makes it very hard to
determine the parent item from a child QModelIndex without duplicating all
the data from the db.  (Or at least I'm finding it very difficult)  So what
I was doing was putting a tuple into the internal pointer parameter.  The
tuple contained a reference to the parent object, the parent object row
(used to determine if data has been added or removed from the database) and
a reference to the child node.  But when the getNodeFromIndex routine gets
called, the tuple that was assigned to the ptr has been garbage collected
and I get a NotImplementedType and generally a crash with an error such as:

*** glibc detected *** python: double free or corruption (fasttop):
0x08619a78 ***

Does anyone have any ideas?  If people feel that the reference counter
should be incremented, I can look at patching the source, but I'm not sure
that's the right thing.

Thanks in advance.

Doug Nichols
doug16 at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20080914/499007f0/attachment.html

More information about the PyQt mailing list