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>
This commit is contained in:
parent
e61fc701e4
commit
a37660ff5f
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user