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>
This commit is contained in:
parent
a7d6efb6e3
commit
0d8789ad30
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user