[PyQt] Strange behavior with new-style signals and slots

Detlev Offenbach detlev at die-offenbachs.de
Sun Apr 1 12:04:30 BST 2012


Hallo,

I am observing a strange behavior related to new-style signal and slots. Here 
is the situation.

My program calls this line twice in a class (via different code paths).

self.project.projectPropertiesChanged.connect(self.__projectPropertiesChanged)

The disconnect is only issued once when the class (the editor) is closed.

self.project.projectPropertiesChanged.disconnect(self.__projectPropertiesChanged)

If the signal is emitted thereafter, I get a RuntimeError saying, that the 
underlying C/C++ object has been destroyed. I suspect, that the Python wrapper 
for the Qt object (here it is a QScintilla object) is still kept alive by some 
reference counter (possibly caused by the double connection).

Is this a bug in PyQt/sip or do I have to avoid such a situation? If the later 
is the case, is it possible to check, if a signal is already connected, e.g. 
something like

self.project.projectPropertiesChanged.is_connected(self.__projectPropertiesChanged)

Another consequence of the double connection is, that the slot is called twice 
when the signal is emitted.

Regards,
Detlev
-- 
Detlev Offenbach
detlev at die-offenbachs.de


More information about the PyQt mailing list