diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-10-14 09:23:45 +0200 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-12-02 09:09:31 +0000 |
commit | d36c21aa8f48aed7775a6a047197b6f6f9055430 (patch) | |
tree | c163c7d6ccc0a0db2ad7cc38525b9e3b89d1908f | |
parent | f69fc16967056b39dd7ead7172926ecc5e92e08b (diff) |
SignalTransition: guard against deleted object
If the object has been deleted, we can not retrieve the sender and
signalIndex anymore. In that case, the only thing we can do is to print
a warning.
This is impossible to trigger during normal usage from C++, however
it can happen in QML, where we do not disconnect handlers soon enough.
This issue only exists in Qt 5, as in Qt 6
c249edb83fa67b3e5f711b28923397e66876182d in qtdeclarative and a few
other changes take care of it.
A testcase for this issue will be added to qtdeclarative.
Fixes: QTBUG-65926
Change-Id: I694a77672c311039c4fe238d9e24c91a427e85e3
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r-- | src/corelib/statemachine/qstatemachine.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index 92d9b67165..a0078b627d 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -3139,7 +3139,10 @@ void QSignalEventGenerator::execute(void **_a) if (machinePrivate->state != QStateMachinePrivate::Running) return; int signalIndex = senderSignalIndex(); - Q_ASSERT(signalIndex != -1); + if (signalIndex == -1) { + qWarning() << "StateMachine: Could not execute transition because originating object has been deleted"; + return; + } machinePrivate->handleTransitionSignal(sender(), signalIndex, _a); } |