On 05.04.07 17:19:56, Phil Thompson wrote: > On Thursday 05 April 2007 3:02 pm, Andreas Pakulat wrote: > > 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... > > An internal pointer is always valid if you still have a reference to the > actual data.
Yes, but if you don't have a reference anymore to an object, you can still access internalPointer() and try to do something with whatever it returns -> crash. With an internalId you get a nice exception which can be caught. > The internal ID would be useful if the value returned by internalId() was the > same size (ie. an int) as that passed to createIndex(). My Qt4.3 docs say createIndex takes a quint32 now, while internalId() returns a quint64. Now if thats not strange I don't know what is... I guess I should report this to TT. Would it be better to have a quint32 or a quint64 here? > > Uhm, I just tested the following code, maybe this helps in finding the > > cause. The output here is: > > -1211419440 3083330668 3083330668 > > The first number makes no sense. I would expect it to be -1211636628. I guess -121163... is the negative max of an int in 32bit? Anyway, what I find weird is that internalPointer == id in this case, while this obviously doesn't work in real world examples > You could put printf()s in the SIP generated code to make absolutely sure. > Look for the function meth_QAbstractItemModel_createIndex(). The only way it > could be happening is if the convertion to an int raised an exception. Tried printfs and fprintfs (to stderr), but I don't see anything when running the python application... sip+PyQt4 is built in debug mode, do I need to do something else? Andreas -- You will receive a legacy which will place you above want. _______________________________________________ PyQt mailing list [email protected] http://www.riverbankcomputing.com/mailman/listinfo/pyqt
