summaryrefslogtreecommitdiffstats
path: root/src/corelib/statemachine
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2011-01-26 11:01:19 (GMT)
committerKent Hansen <kent.hansen@nokia.com>2011-01-26 11:01:19 (GMT)
commit1c79a42d6b0f6c15a0472e0cde3742d0c504ead3 (patch)
tree793c6b796de08f62bd0bbc1b372b12fda5f85b93 /src/corelib/statemachine
parente881b19ba3f2f4bfda460e1a043f461fb0517d70 (diff)
downloadQt-1c79a42d6b0f6c15a0472e0cde3742d0c504ead3.zip
Qt-1c79a42d6b0f6c15a0472e0cde3742d0c504ead3.tar.gz
Qt-1c79a42d6b0f6c15a0472e0cde3742d0c504ead3.tar.bz2
Make sure QStateMachine stops when it's told to
If QStateMachine::stop() was called by an event test or while transitioning to another state, the state machine could end up in an inconsistent internal state (stop==true, but the stopped() signal was not emitted). This also caused the machine to behave incorrectly if it was then restarted (it would immediately stop upon receiving the first event). Solution: Move the stop-handling after the event processing loop, so that it always takes precedence over other possible reasons for exiting the loop (event queues exhausted, final state entered). Task-number: QTBUG-16463 Reviewed-by: Eskil Abrahamsen Blomfeldt
Diffstat (limited to 'src/corelib/statemachine')
-rw-r--r--src/corelib/statemachine/qstatemachine.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp
index 392c45d..b2af5ca 100644
--- a/src/corelib/statemachine/qstatemachine.cpp
+++ b/src/corelib/statemachine/qstatemachine.cpp
@@ -1245,9 +1245,7 @@ void QStateMachinePrivate::_q_process()
#endif
while (processing) {
if (stop) {
- stop = false;
processing = false;
- stopProcessingReason = Stopped;
break;
}
QSet<QAbstractTransition*> enabledTransitions;
@@ -1299,6 +1297,11 @@ void QStateMachinePrivate::_q_process()
#ifdef QSTATEMACHINE_DEBUG
qDebug() << q << ": finished the event processing loop";
#endif
+ if (stop) {
+ stop = false;
+ stopProcessingReason = Stopped;
+ }
+
switch (stopProcessingReason) {
case EventQueueEmpty:
break;