[PySide] Bug with new hash table feature

John Ehresman jpe at wingware.com
Wed Jun 13 22:45:20 CEST 2012


On 5/30/12 3:35 PM, John Ehresman wrote:
>> Can we use the address of the Shiboken object as the hash value?  That
>> remains valid so long as there are references to the object, even after
>> the object itself has been deleted in C++ land.
>
> This works if there can only be one wrapper at a time for a given
> QObject.  I don't know if this is the case.

I just ran into this bug and tried to apply the patch locally, but ran 
into poblems.  If the address of the PyObject* can be used, I think that 
would be preferable.  Consider the following:

     o = QObject()
     d = {}
     d[o] = 1
     def on_destroy():
         d.pop(o)
     o.destroyed.connect(on_destroy)
     shiboken.delete(o)

The pop in the destroy handler will fail with a RuntimeError and even if 
the RuntimeError is suppressed and a default hash value returned, the 
entry in the dictionary won't be found or removed.

John



More information about the PySide mailing list