[PySide] QObject.destroyed() is not emitted
Stephan Deibel
sdeibel at wingware.com
Thu Nov 29 18:37:47 CET 2012
Alexey Vihorev wrote:
> Thanks, nice find, but... I hit the next hurdle trying to go this way. The signal QObject.destroyed(obj) is passing no arguments (probably because obj is already destroyed), so my static method has nothing to work on. Which kind of devaluates the whole idea, IMHO. And in PyQt4 it*does* pass the object. Even more: in PyQt4 there is no need for static method approach, as it works perfectly with instance methods:
Yea, you would have to bind the necessary data to the callback like this:
def on_destroy(val1=self.whatever, val2=self.something):
print 'destroyed'
self.destroyed.connect(on_destroy)
Whether this is possible or useful in your case is of course going to depend on the details of the code.
Having 'destroyed' be emitted before the object is destroyed and getting the object reference as an arg makes more sense to me. That is what PyQt seems to do and it is what QObject does under Qt using C++, so I'd call this a bug in PySide. I've added https://bugreports.qt-project.org/browse/PYSIDE-129
- Stephan
More information about the PySide
mailing list