[PyKDE] Problem (re)connecting QWizard buttons
phil at riverbankcomputing.co.uk
Sat Jun 25 12:37:32 BST 2005
On Friday 24 June 2005 11:16 am, Ulrich Berning wrote:
> Look at the following code:
> (Yes, I know that reimplementing accept() is the better way)
> import sys
> from qt import *
> class MyWizard(QWizard):
> def __init__(self,parent=None,name="",modal=False,fl=0):
> # Disconnect the default slot
> self, SLOT('accept()'))
> # With the lastest sip/PyQt snapshots,
> # this additional reference is necessary
> # *before* we connect to our own slot
> # ---
> # With sip-4.2.1/PyQt-3.14.1, this
> # additional reference wasn't necessaray.
> # Is this a bug or an intentional change?
> self.fb = self.finishButton()
> # Connect to our own slot
> def myFinishSlot(self):
> print "myFinishSlot()"
> if __name__ == "__main__":
> a = QApplication(sys.argv)
> QObject.connect(a, SIGNAL("lastWindowClosed()"),
> a, SLOT("quit()"))
> w = MyWizard()
> With the latest sip/PyQt snapshots, I have to store an additional
> reference to the finishButton instance before I connect the signal to my
> own slot, otherwise the slot gets never called.
> With sip-4.2.1/PyQt-3.14.1 this additional reference wasn't necessary.
> Is this a bug or an intentional change? I haven't found anything
> specific in the ChangeLogs.
It's a side-effect of the new support for the cyclic garbage collector. For
connections to Python callables a proxy QObject is created. This was being
destroyed when the signal emitter was garbage collected.
I've changed it so that the proxy is only destroyed if the signal emitter is
owned by Python.
More information about the PyQt