diff options
author | Kent Hansen <kent.hansen@nokia.com> | 2010-03-22 13:00:02 (GMT) |
---|---|---|
committer | Kent Hansen <kent.hansen@nokia.com> | 2010-03-22 13:05:55 (GMT) |
commit | c1e23f855826942d7d3821a944c35272d9ecffb4 (patch) | |
tree | b1dd4858cb33485a55c1cbe9d290240de02c9b70 /src | |
parent | 4b40231458a6df067e74047842073a445880b686 (diff) | |
download | Qt-c1e23f855826942d7d3821a944c35272d9ecffb4.zip Qt-c1e23f855826942d7d3821a944c35272d9ecffb4.tar.gz Qt-c1e23f855826942d7d3821a944c35272d9ecffb4.tar.bz2 |
Reset history states when (re)starting state machine
State saved in QHistoryState should not be persistent between
state machine starts/stops.
Task-number: QTBUG-8842
Reviewed-by: Eskil Abrahamsen Blomfeldt
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/statemachine/qstatemachine.cpp | 11 | ||||
-rw-r--r-- | src/corelib/statemachine/qstatemachine_p.h | 2 |
2 files changed, 13 insertions, 0 deletions
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index bd7e626..9d5c49f 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -1175,6 +1175,16 @@ void QStateMachinePrivate::removeStartState() _startState = 0; } +void QStateMachinePrivate::clearHistory() +{ + Q_Q(QStateMachine); + QList<QHistoryState*> historyStates = qFindChildren<QHistoryState*>(q); + for (int i = 0; i < historyStates.size(); ++i) { + QHistoryState *h = historyStates.at(i); + QHistoryStatePrivate::get(h)->configuration.clear(); + } +} + void QStateMachinePrivate::_q_start() { Q_Q(QStateMachine); @@ -1186,6 +1196,7 @@ void QStateMachinePrivate::_q_start() internalEventQueue.clear(); qDeleteAll(externalEventQueue); externalEventQueue.clear(); + clearHistory(); #ifdef QSTATEMACHINE_DEBUG qDebug() << q << ": starting"; diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h index 0fead5d..5e1015f 100644 --- a/src/corelib/statemachine/qstatemachine_p.h +++ b/src/corelib/statemachine/qstatemachine_p.h @@ -126,6 +126,8 @@ public: QState *startState(); void removeStartState(); + void clearHistory(); + void microstep(QEvent *event, const QList<QAbstractTransition*> &transitionList); bool isPreempted(const QAbstractState *s, const QSet<QAbstractTransition*> &transitions) const; QSet<QAbstractTransition*> selectTransitions(QEvent *event) const; |