[PyQt] Re: Debugging memory corruption b/c of invalid GIL usage

Kevin Watters kevinwatters at gmail.com
Tue Aug 12 17:15:46 BST 2008

Turns out (one) of my problems was %GCClearCode that was being invoked
after a C++ object's destructor.

There's a note in sipWrapper_dealloc about calling sipWrapper_clear
after td_dealloc:

 Now that the C++ object no longer exists we can tidy up the Python
 object.  We used to do this first but that meant lambda slots were
 removed too soon (if they were connected to QObject.destroyed()).
As far as I can tell, for objects with public virtual destructors, this
means SIP will call the C++ destructor first, and then the attached
%GCClearCode. The %GCClearCode documentation doesn't mention this,

Moving sipWrapper_clear above the td_dealloc fixed one of my crashes. :)

- Kevin

More information about the PyQt mailing list