[PyKDE] Regression caused by lambda as slots
Giovanni Bajo
rasky at develer.com
Wed Jan 17 17:09:13 GMT 2007
Hello Phil,
I think I have managed to produce a (convoluted) testcase for what
appears to be a reference leak introduced by recent SIP versions. It
ought to be when you added support for lambda expressions as slots.
============================================================
from qt import *
app = QApplication([])
class FooBar(QObject):
def __init__(self, parent):
QObject.__init__(self, parent)
a = QObject(None)
a._slot = lambda: parent+a # get a reference to both
QObject.connect(a, PYSIGNAL("FOOBAR"), a._slot)
b = QWidget(None)
FooBar(b)
# Keep track of whether "b" is really destroyed or not
dlist = []
def destroyed():
print "destroyed"
dlist.append(1)
QObject.connect(b, SIGNAL("destroyed()"), destroyed)
del b
import gc
gc.collect()
gc.collect()
gc.collect()
gc.collect()
assert dlist
============================================================
This asserts for me on recent SIP snapshots (200701115), but works with
4.4.5.
--
Giovanni Bajo
More information about the PyQt
mailing list