summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2012-07-07 04:51:24 +0200
committerQt by Nokia <qt-info@nokia.com>2012-07-11 08:42:36 +0200
commit0d8789ad300c2950855176e17cb17d7b1e7f39f9 (patch)
treedda9d80682d827977174658f883693894ac891f5 /src
parenta7d6efb6e3c0f8fddf95d121f856b00d552f3a08 (diff)
statemachine: Small refactoring of initial transition code
In preparation of supporting parallel root states, which will make the initial transition creation slightly more involved. Change-Id: Iad996eb4db248842c1a2088430c13bd5c953c374 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/statemachine/qstatemachine.cpp30
-rw-r--r--src/corelib/statemachine/qstatemachine_p.h1
2 files changed, 16 insertions, 15 deletions
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp
index 2e37af3194..f1ca421de2 100644
--- a/src/corelib/statemachine/qstatemachine.cpp
+++ b/src/corelib/statemachine/qstatemachine.cpp
@@ -1281,20 +1281,22 @@ void QStateMachinePrivate::initializeAnimations(QAbstractState *state, const QLi
#endif // !QT_NO_ANIMATION
-namespace {
-
-class InitialTransition : public QAbstractTransition
+QAbstractTransition *QStateMachinePrivate::createInitialTransition() const
{
-public:
- InitialTransition(QAbstractState *target)
- : QAbstractTransition()
- { setTargetState(target); }
-protected:
- virtual bool eventTest(QEvent *) { return true; }
- virtual void onTransition(QEvent *) {}
-};
+ class InitialTransition : public QAbstractTransition
+ {
+ public:
+ InitialTransition(QAbstractState *target)
+ : QAbstractTransition()
+ { setTargetState(target); }
+ protected:
+ virtual bool eventTest(QEvent *) { return true; }
+ virtual void onTransition(QEvent *) {}
+ };
-} // namespace
+ Q_ASSERT(rootState() != 0);
+ return new InitialTransition(rootState()->initialState());
+}
void QStateMachinePrivate::clearHistory()
{
@@ -1310,8 +1312,6 @@ void QStateMachinePrivate::_q_start()
{
Q_Q(QStateMachine);
Q_ASSERT(state == Starting);
- Q_ASSERT(rootState() != 0);
- QAbstractState *initial = rootState()->initialState();
configuration.clear();
qDeleteAll(internalEventQueue);
internalEventQueue.clear();
@@ -1326,7 +1326,7 @@ void QStateMachinePrivate::_q_start()
processingScheduled = true; // we call _q_process() below
QList<QAbstractTransition*> transitions;
- QAbstractTransition *initialTransition = new InitialTransition(initial);
+ QAbstractTransition *initialTransition = createInitialTransition();
transitions.append(initialTransition);
QEvent nullEvent(QEvent::None);
diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h
index c68ff411b1..423c077a83 100644
--- a/src/corelib/statemachine/qstatemachine_p.h
+++ b/src/corelib/statemachine/qstatemachine_p.h
@@ -128,6 +128,7 @@ public:
QState *rootState() const;
void clearHistory();
+ QAbstractTransition *createInitialTransition() const;
void microstep(QEvent *event, const QList<QAbstractTransition*> &transitionList);
bool isPreempted(const QAbstractState *s, const QSet<QAbstractTransition*> &transitions) const;