[PyKDE] Python references and the GC
Kaleb Pederson
kibab at icehouse.net
Wed Oct 30 01:19:01 GMT 2002
I have a class similar to the below that keeps a reference to itself so that
it doesn't get garbage collected.
class sample(qdialog):
def __init__(...):
qwidget.__init__(...)
self._keep = self
...
def closeEvent(self,event):
self._keep = None
...
class ...(QWidget):
def myfunc(self):
inst = sample(0,name,FALSE) # created so its modeless with no parent
self.connect(self,PYSIGNAL("closing()"),inst.closeMe)
return
When should I delete the reference to the object? When WDestructive close is
passed as a parameter I get the following:
Traceback (most recent call last):
File "/home/kibab/.../src/gui/MainInterfaceImpl.py", line 1346, in
closeEvent
self.emit(PYSIGNAL("closeChild()"),() )
RuntimeError: Underlying C/C++ object has been deleted
However, the documentation says:
"Note that when a slot is a Python callable object it's reference count is not
increased. This means that a class instance can be deleted without having to
explicitly disconnect any signals connected to its methods."
(http://www.riverbankcomputing.co.uk/pyqt/docs/x225.html).
Disconnecting doesn't work, however, per my last post.
What do other people do when they want to have a modeless non-parented dialog?
Thanks.
--Kaleb
More information about the PyQt
mailing list