*** GMX Spamverdacht *** Re: *** GMX Spamverdacht *** Re: [PyQt] Bug in QAbstractItemModel::createIndex()?

Andreas Pakulat apaku at gmx.de
Thu Apr 5 15:02:29 BST 2007


On 05.04.07 14:21:44, Phil Thompson wrote:
> On Thursday 05 April 2007 1:12 pm, Andreas Pakulat wrote:
> > On 05.04.07 12:14:01, Phil Thompson wrote:
> > > The spelling of itemdict on line 120 - the line that generates all those
> > > exception messages. Maybe you didn't attach the version you intended to.
> >
> > Uhm, right, overlooked that one.
> > But the problem still persists, what I see here is:
> > KeyError: -1212033192L
> > Traceback (most recent call last):
> >   File "simpletreemodel.py", line 88, in data
> >     item = self.itemdict[index.internalId()]
> > KeyError: -1212033192L
> > Traceback (most recent call last):
> >   File "simpletreemodel.py", line 88, in data
> >     item = self.itemdict[index.internalId()]
> > KeyError: -1212033096L
> >
> > And that is with the latest snapshot. I have absolutely no idea how that
> > can happen and so far it seems I'm the only one seeing this.
> 
> Jeremy Sanders posted about a similar problem last August. Attached is his 
> test script. He was getting the same values on a 32 bit system but different 
> values on a 64 bit system.

I'm not on 64Bit system, this is a plain 32Bit Linux running Python 2.5
using shared python lib.

> You getting different values would explain the behaviour you are seeing. 
> However I get the same values on both 32 and 64 bit systems - but none of my 
> values go negative.

Hmm, you have any idea where this might come from? I'm prepared to dig
into this as its keeping me from trying some things with eric4's VCS...

> Certainly internalPointer() should be used in preference to internalId().

Well, the problem with internalPointer is that you can't easily check
wether the object it carries is valid. With internalId you get an
KeyError when trying to index into the dict...

Uhm, I just tested the following code, maybe this helps in finding the
cause. The output here is:
-1211419440 3083330668 3083330668

,----
| from PyQt4 import QtCore
| class c(QtCore.QAbstractItemModel):
|    pass
| a=c()
| i=id(a)
| x=a.createIndex(0,0,i)
| print x.internalId(),x.internalPointer(),i
`----

Correct me if I'm wrong, but could it be that due to the fact that id()
returns a python object the 2nd overload for createIndex is used? I
tried to use this in the simpletreemodel.py but it still throws key
errors with negative values. If I try to give createIndex() an int-object
that the model keeps a reference to (i.e.
self.itemdict.keys().index(id(item))) then I get a segfault. I'll
rebuild with debug symbols now...

Andreas

-- 
You will be winged by an anti-aircraft battery.


More information about the PyQt mailing list