diff options
author | Kent Hansen <kent.hansen@nokia.com> | 2012-07-07 05:43:11 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-11 08:42:40 +0200 |
commit | 28e9a602cb35fc621dec36e28e8556ca0052551e (patch) | |
tree | 06a4c556acd1fdfaca484a350f355cac59ed6222 /src/corelib | |
parent | 0d8789ad300c2950855176e17cb17d7b1e7f39f9 (diff) |
statemachine: Emit finished() signal when the initial state is final
It's legal to set a QFinalState as the initial state. The state
machine should correctly emit the finished() signal upon entering
such a state in the initial transition, and don't do any further
processing.
Change-Id: Ica8d3fadbbde604512ea1136624af54eb3b13b11
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/statemachine/qstatemachine.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index f1ca421de2..6412d7a0a9 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -1341,6 +1341,9 @@ void QStateMachinePrivate::_q_start() #ifndef QT_NO_ANIMATION QList<QAbstractAnimation*> selectedAnimations = selectAnimations(transitions); #endif + // enterStates() will set stopProcessingReason to Finished if a final + // state is entered. + stopProcessingReason = EventQueueEmpty; enterStates(&nullEvent, exitedStates, enteredStates, statesForDefaultEntry, assignmentsForEnteredStates #ifndef QT_NO_ANIMATION @@ -1355,7 +1358,15 @@ void QStateMachinePrivate::_q_start() emit q->started(); - _q_process(); + if (stopProcessingReason == Finished) { + // The state machine immediately reached a final state. + processingScheduled = false; + state = NotRunning; + unregisterAllTransitions(); + emit q->finished(); + } else { + _q_process(); + } } void QStateMachinePrivate::_q_process() |