From a37660ff5f4051a4a28b02c02c5ec05cbbd8369d Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Sat, 7 Jul 2012 04:13:21 +0200 Subject: [PATCH] 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 --- src/corelib/statemachine/qstatemachine.cpp | 17 +++++++---------- 1 file 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::const_iterator it; - for (it = configuration.constBegin(); it != configuration.constEnd(); ++it) { - sourceState = toStandardState(*it); - if (sourceState != 0) - break; - } - } else { - sourceState = startState(); - } + QSet::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