<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Message: 1<br>
Date: Sun, 01 Apr 2012 13:04:30 +0200<br>
From: Detlev Offenbach <<a href="mailto:detlev@die-offenbachs.de">detlev@die-offenbachs.de</a>><br>
To: <a href="mailto:pyqt@riverbankcomputing.com">pyqt@riverbankcomputing.com</a><br>
Subject: [PyQt] Strange behavior with new-style signals and slots<br>
Message-ID: <1362374.ZZnnlU3EYs@jupiter><br>
Content-Type: text/plain; charset="us-ascii"<br>
<br>
Hallo,<br>
<br>
I am observing a strange behavior related to new-style signal and slots. Here<br>
is the situation.<br>
<br>
My program calls this line twice in a class (via different code paths).<br>
<br>
self.project.projectPropertiesChanged.connect(self.__projectPropertiesChanged)<br>
<br>
The disconnect is only issued once when the class (the editor) is closed.<br>
<br>
self.project.projectPropertiesChanged.disconnect(self.__projectPropertiesChanged)<br>
<br>
If the signal is emitted thereafter, I get a RuntimeError saying, that the<br>
underlying C/C++ object has been destroyed. I suspect, that the Python wrapper<br>
for the Qt object (here it is a QScintilla object) is still kept alive by some<br>
reference counter (possibly caused by the double connection).<br>
<br>
Is this a bug in PyQt/sip or do I have to avoid such a situation? If the later<br>
is the case, is it possible to check, if a signal is already connected, e.g.<br>
something like<br>
<br>
self.project.projectPropertiesChanged.is_connected(self.__projectPropertiesChanged)<br>
<br>
Another consequence of the double connection is, that the slot is called twice<br>
when the signal is emitted.<br>
<br>
Regards,<br>
Detlev<br>
--<br>
Detlev Offenbach<br>
<a href="mailto:detlev@die-offenbachs.de">detlev@die-offenbachs.de</a><br>
<br></blockquote><div><br>Detlev,<br><br>Perhaps you want to make use of Qt::UniqueConnection as the connection type.<br><br>Note that I believe this will only work correctly on a slot decorated with pyqtSlot (or that was previously the case anyhow)<br>
<br>- MH<br> </div></div>