On Tue, 15 Sep 2009 17:57:44 +0200, Florian Reinhard <florian.reinh...@googlemail.com> wrote: > This testcase causes a segfault in 4.5.4 works in 4.4.4 > > from PyQt4.QtCore import QVariant, QObject > > class Test (QObject): > def __init__ (self,parent=None): > super(Test,self).__init__ (parent) > self.foo = 'bar' > > def uuu (self): > print self.foo > > class Wrapper (QObject): > def __init__ (self,parent=None): > super(Wrapper,self).__init__ (parent) > test = Test () > self.test = QVariant (test) > > def aaa (self): > self.test.toPyObject ().uuu () > > foo = Wrapper () > foo.aaa()
Unfortunately it's the correct behaviour - or the least incorrect behaviour anyway. You need to keep a reference to the "test" object - QVariant won't do it for you. In previous versions QVariant wrapped the object in something that maintained the reference count. However that meant (for QObject sub-classes) it wasn't recognised as a QObject and so couldn't be used by JavaScript etc. I've updated the documentation to cover this. It only affects QObject sub-classes. Phil _______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt