[PyQt] pyqt circular references & garbage collection
charles.chen at temboo.com
Tue Jul 31 21:11:07 BST 2007
Thanks Phil for your help with our memory lapse.
We've come across another issue: the Python garbage collector isn't sussing out circular references properly.
A previous post by you say that this should be working:
Here's a simple demonstration:
>>> from PyQt4.QtCore import QObject
>>> class q(QObject):
... def init(self):
... def __del__(self):
... print 'q deleted.'
>>> q1 = q()
>>> q1 = None
>>> q2 = q()
>>> q2.circularReference = q2
>>> q2 = None
>>> q3 = q()
>>> q3.circularReference = q3
>>> q3 = None
>>> import gc
>>> q4 = q()
>>> q4.circularReference = q4
>>> q4.circularReference = None
>>> q4 = None
q2 and q3 are never gc'ed.
We're also seeing this in production. Are we doing something wrong?
Phil Thompson <phil at riverbankcomputing.co.uk> wrote: On Monday 30 July 2007 5:16 pm, charles chen wrote:
> We're having trouble seeing the QMdiArea's subWindowActivated signal.
> Is this related to the "signal/slot handling fix." from 7/16-7/20?
> We're using:
> The relevant code:
> self.__workspace__ = QMdiArea()
> QObject.connect( self.__workspace__, SIGNAL('subWindowActivated (
> QMdiSubWindow * window )'), self.handleSubwindowActivated )
> def handleSubwindowActivated(self, ignore=None ):
> Here's a link to the Qt docs of the signal:
Don't pass argument names to SIGNAL().
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the PyQt