[PyQt] Signals arriving after proxy slots deleted

Andrew Suffield asuffield at suffields.me.uk
Mon Apr 16 10:59:20 BST 2012


Pretty sure it's a pyqt bug, in deleteSlotProxies:

            if (QThread::currentThread() == up->thread())
                delete up;
            else
                up->deleteLater();

http://qt-project.org/doc/qt-4.8/qobject.html#dtor.QObject

"Warning: Deleting a QObject while pending events are waiting to be
 delivered can cause a crash. [...] Use deleteLater() instead, which
 will cause the event loop to delete the object after all pending
 events have been delivered to it."

Qt makes no effort to clean out pending events when an object is
deleted. deleteSlotProxies has no reason to believe that pending
events are not waiting to be delivered - and in the case I have, there
are pending events. It should use deleteLater unconditionally.

In fact I would suggest that it is probably always wrong for pyqt to
delete a QObject rather than deleteLater, since it has no idea what
the application code may have in the event queue.


More information about the PyQt mailing list