[PyQt] Signals and "RuntimeError: wrapped C/C++ object of type XXX has been deleted"

Jeremy Sanders jeremy at jeremysanders.net
Wed Nov 20 19:27:43 GMT 2013


On 20/11/13 20:14, Phil Thompson wrote:
> On Wed, 20 Nov 2013 19:57:07 +0100, Jeremy Sanders
> <jeremy at jeremysanders.net> wrote:
>> Is this a bug? I've managed to fix a couple of these where it's obvious
>> where the widget is deleted, so I disconnect the signal first. In other
>> places I can't see an obvious way to do this - where can I clear up
>> signals of random widgets? This seems like a hack and I would have
>> thought that signals should be deleted before the C++ object is deleted.
>
> It's possible there is some sort of race condition, but difficult to tell
> without an example.
>
> The use of Python signals and slots can create proxies at both end of the
> connection. Moving to new-style signals (and maybe decorated slots) should
> simplify things.

Thanks Phil. I can reliably reproduce this with my plotting package, but 
this is 60,000 lines of code. Unfortunately I haven't found a way to 
reproduce this in an simple program. It's probably due to the complex 
set of signals, slots and mutual references.

I'll see whether I can swap this signal to a new style one and see 
whether the problem can still be reproduced.

Jeremy



More information about the PyQt mailing list