[PyQt] Again, problems with garbage collection

Martin Teichmann lkb.teichmann at gmail.com
Thu Mar 18 14:48:25 GMT 2010


Hi List,

I just upgraded to PyQt4 4.7.2 (with Python 2.6.4 on Windows XP)
and the following little script crashes with "unterlying C/C++ object
has been deleted"

I guess that's a bug.

------------------- snip ------------------------------
from PyQt4.QtCore import QObject, SIGNAL, QCoreApplication

# following two lines not important
from sys import argv
app = QCoreApplication(argv)

class A(QObject):
    def __init__(self, p=None):
        QObject.__init__(self, p)

    def g(self):
        self.emit(SIGNAL("sig"))

    def f(self):
        print "hello"

    def kill(self):
        self.setParent(None)

b = A()
a = A(b)

b.connect(a, SIGNAL("sig"), b.f)
a.g()
b.kill()
b = None
a.g()
------------------------------- snip -------------------------

greetings

Martin


More information about the PyQt mailing list