summaryrefslogtreecommitdiffstats
path: root/src/corelib/statemachine/qabstracttransition.cpp
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@digia.com>2015-06-18 16:45:32 +0200
committerErik Verbruggen <erik.verbruggen@theqtcompany.com>2015-07-23 13:29:46 +0000
commit5fd9fe02ff14438a2d0c93789be138a58583dbe8 (patch)
tree4532d254a6ae22834948c61b81c1876d8beb7719 /src/corelib/statemachine/qabstracttransition.cpp
parent5329d739eed83cc9f430f9d97652743558ccd146 (diff)
QStateMachine: add defaultTransition in QHistoryState
The history state had the limitation that it was hard (or impossible) to use when more than one default state had to be entered. For example, using it in a parallel state was impossible without ending up in an infinite loop. This patch changes the QHistoryState to only have an initial transition, and the state selection algorithm is changed accordingly. It also brings QStateMachine closer to the SCXML standard. The existing defaultState is implemented on top of the defaultTransition: when used, a new transition, with the default state as its target, is set as the defaultTransition. Task-number: QTBUG-46703 Change-Id: Ifbb44e4f0f26b72e365af4c94753e4483f9850e7 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
Diffstat (limited to 'src/corelib/statemachine/qabstracttransition.cpp')
-rw-r--r--src/corelib/statemachine/qabstracttransition.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/corelib/statemachine/qabstracttransition.cpp b/src/corelib/statemachine/qabstracttransition.cpp
index 92a5d373fe..5a7a95883b 100644
--- a/src/corelib/statemachine/qabstracttransition.cpp
+++ b/src/corelib/statemachine/qabstracttransition.cpp
@@ -37,6 +37,7 @@
#include "qabstracttransition_p.h"
#include "qabstractstate.h"
+#include "qhistorystate.h"
#include "qstate.h"
#include "qstatemachine.h"
@@ -135,10 +136,12 @@ QAbstractTransitionPrivate::QAbstractTransitionPrivate()
QStateMachine *QAbstractTransitionPrivate::machine() const
{
- QState *source = sourceState();
- if (!source)
- return 0;
- return source->machine();
+ if (QState *source = sourceState())
+ return source->machine();
+ Q_Q(const QAbstractTransition);
+ if (QHistoryState *parent = qobject_cast<QHistoryState *>(q->parent()))
+ return parent->machine();
+ return 0;
}
bool QAbstractTransitionPrivate::callEventTest(QEvent *e)