summaryrefslogtreecommitdiffstats
path: root/src/corelib/statemachine
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2012-07-04 23:17:49 +0200
committerQt by Nokia <qt-info@nokia.com>2012-07-10 06:21:01 +0200
commitd219ea1ebcd8dee171dab279498961d68dac8812 (patch)
tree0e2ea598fa50982e10dfe5560732c7ba7de84874 /src/corelib/statemachine
parentd2a6f8e6dd96b015e2fe5c098331f0fd6387ce43 (diff)
statemachine: Don't assign properties for transitions with no targets
If the transition has no target states, that means the current state won't change; hence, property assignments should not be performed. In particular, properties should not be restored to the values they had before the state was entered. Change-Id: I237bbb541f939c272777e70c5f26c886ec457a17 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Diffstat (limited to 'src/corelib/statemachine')
-rw-r--r--src/corelib/statemachine/qstatemachine.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp
index 276e3f603f..b64a0f5eb3 100644
--- a/src/corelib/statemachine/qstatemachine.cpp
+++ b/src/corelib/statemachine/qstatemachine.cpp
@@ -378,7 +378,8 @@ void QStateMachinePrivate::microstep(QEvent *event, const QList<QAbstractTransit
executeTransitionContent(event, enabledTransitions);
QList<QAbstractState*> enteredStates = enterStates(event, enabledTransitions);
#ifndef QT_NO_PROPERTIES
- applyProperties(enabledTransitions, exitedStates, enteredStates);
+ if (!enteredStates.isEmpty()) // Ignore transitions with no targets
+ applyProperties(enabledTransitions, exitedStates, enteredStates);
#endif
#ifdef QSTATEMACHINE_DEBUG
qDebug() << q_func() << ": configuration after entering states:" << configuration;
@@ -662,6 +663,7 @@ void QStateMachinePrivate::applyProperties(const QList<QAbstractTransition*> &tr
#else
Q_Q(QStateMachine);
#endif
+ Q_ASSERT(!enteredStates.isEmpty());
// Process the property assignments of the entered states.
QHash<QAbstractState*, QList<QPropertyAssignment> > propertyAssignmentsForState;
QHash<RestorableId, QVariant> pendingRestorables = registeredRestorables;
@@ -705,11 +707,7 @@ void QStateMachinePrivate::applyProperties(const QList<QAbstractTransition*> &tr
}
}
if (!pendingRestorables.isEmpty()) {
- QAbstractState *s;
- if (!enteredStates.isEmpty())
- s = enteredStates.last(); // ### handle if parallel
- else
- s = 0;
+ QAbstractState *s = enteredStates.last(); // ### handle if parallel
propertyAssignmentsForState[s] << restorablesToPropertyList(pendingRestorables);
}