[PyQt] Slots being called on deleted QObjects
Jeremy Sanders
jeremy at jeremysanders.net
Sun Apr 6 17:39:30 BST 2014
Phil Thompson wrote:
> That would be an incompatible change. Any slot can be called from any
> signal. The problem only arises if you try to do something that requires
> the underlying C++ QObject. The comment mentions destroyed() only
> because that was the context in which the bug was reported (and it is
> guaranteed to happen with that particular signal) but it can apply to
> any signal.
Thanks Phil. These are QWidgets which I'm modifying when my program emits a
documentChanged() signal. There are race conditions where documentChanged()
is emitted after the Qt object has been deleted. This seems quite nasty as
you get random crashes which are hard to test for.
Is using @pyqtSlot the only workaround? Should I be using this for every
slot which does something to the QObject if the signal is emitted from
Python?
I assume the @pyqtSlot works because the signal is delivered via Qt and
therefore never makes it because there is no Qt object.
Jeremy
More information about the PyQt
mailing list