diff options
author | Kent Hansen <kent.hansen@nokia.com> | 2012-07-07 04:13:21 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-10 03:25:02 +0200 |
commit | a37660ff5f4051a4a28b02c02c5ec05cbbd8369d (patch) | |
tree | ea96ed41b7d17dad490a621018a795900cb72ec6 /src/corelib/statemachine | |
parent | e61fc701e4110271d3f65c127af85d11cb5a4d28 (diff) |
statemachine: goToState() should require that the machine is running
goToState() is an internal function. Allowing both goToState() and
machine.setInitialState() to be used to set the initial state of the
machine complicates the logic of QStateMachine::start().
The existing tests for goToState() still pass.
Change-Id: Ie831b4c869848f7f4c3e6bd576cf298a9799eb22
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Diffstat (limited to 'src/corelib/statemachine')
-rw-r--r-- | src/corelib/statemachine/qstatemachine.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index 0b8fa3db5b..3d0b1e92fd 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -1468,17 +1468,14 @@ void QStateMachinePrivate::goToState(QAbstractState *targetState) if (configuration.contains(targetState)) return; + Q_ASSERT(state == Running); QState *sourceState = 0; - if (state == Running) { - QSet<QAbstractState*>::const_iterator it; - for (it = configuration.constBegin(); it != configuration.constEnd(); ++it) { - sourceState = toStandardState(*it); - if (sourceState != 0) - break; - } - } else { - sourceState = startState(); - } + QSet<QAbstractState*>::const_iterator it; + for (it = configuration.constBegin(); it != configuration.constEnd(); ++it) { + sourceState = toStandardState(*it); + if (sourceState != 0) + break; + } Q_ASSERT(sourceState != 0); // Reuse previous GoToStateTransition in case of several calls to |