[PyKDE] pysignals and Py_DECREF

Phil Thompson phil at riverbankcomputing.co.uk
Thu May 25 20:47:06 BST 2006


On Monday 22 May 2006 3:38 am, Patrick Stinson wrote:
> I am trying to disconnect all of the signals that I connected to a
> QObject in order to ensure that it is deleted. The following program
> prints "Object::disconnect: No such signal QObject::bleh(QObject*)" if
> I uncomment the disconnect line, but also deletes the object when it
> is dereferenced.

The error message is due a SIP bug - fixed in tonight's snapshot.

> from PyQt4.QtCore import *
>
> class O(QObject):
>     def __init__(self):
>         QObject.__init__(self)
>     def __del__(self):
>         print '__del__'
>
> def slot(o):
>     print o
>
> o = O()
> QObject.connect(o, SIGNAL('bleh(QObject *)'), slot)
> #QObject.disconnect(o, SIGNAL('bleh(QObject *)'), slot)
> o = None
> print 'here'
>
>
> I am posting this because I realized that I have no idea how
> python-defined signals act anymore. I thought that if I connected the
> signal the reference count was incremented, and I had to disconect it
> if I wanted to delete the QObject. is this still true?

It has never been true precisely to avoid having to manually disconnect 
everything.

> Any other 
> relavent commentary regarding references, pysignals, and
> QObject::disconnect?

Phil




More information about the PyQt mailing list