[PyKDE] disconnecting PYSIGNAL
Toby Dickenson
tdickenson at devmail.geminidataloggers.co.uk
Mon Nov 3 11:26:01 GMT 2003
SIGNAL connections get automatically cleaned up by Qt when the recieving C++
object is destroyed. It appears that PYSIGNAL connections get automatically
cleaned up when the recieving python object is destroyed.
I currently have a problem where I am destroying a c++ object (using
deleteLater) but the python object lives on (I guess due to a reference cycle
somewhere). This half-dead object still continues to recieve PYSIGNALS, which
I wasnt expecting. checked with PyQt 3.8.1, qt 3.1.2 on windows, test script
below.
Im sure I will fixing the reference cycle eventually, but I dont want to rely
on that for program correctness. Is this a bug in pyqt? Is there a way to
manually disconnect all PYSIGNALs to an object?
Or perhaps my use of deleteLater is the problem.... is there a better way to
remove closed view windows from a QWorkspace?
Thanks in advance,
from qt import *
class A(QObject):
pass
class B(QObject):
def bbb(self):
print 'in bbb'
print self.children()
print 'dont get here'
a = A()
b = B()
app = QApplication([])
a.connect(a,PYSIGNAL('aaa'),b.bbb)
b.deleteLater()
app.processEvents()
#b = 0 # deleting the python object would make the problem go away
a.emit(PYSIGNAL('aaa'),())
--
Toby Dickenson
More information about the PyQt
mailing list