summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-08-17 10:45:20 +0200
committerLiang Qi <liang.qi@qt.io>2017-08-17 10:45:26 +0200
commit5671c31a5141fed64edbe53fece895b2fd7449d3 (patch)
tree97dd4aebb4f64ea9117cc149fbf64308a3d7b5a0 /src
parentd186096dd9dd26ebbd0d0f8bb699eee8f331250f (diff)
parent5a4550879d30d1897e9b62e4fb73e7392c4182b8 (diff)
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts: .qmake.conf Change-Id: I12855e70c1444b9170f7ab55740bb50448e3dfb0
Diffstat (limited to 'src')
-rw-r--r--src/scxml/doc/qtscxml-instantiating-state-machines.qdoc4
-rw-r--r--src/scxml/qscxmlstatemachine.cpp28
-rw-r--r--src/scxml/qscxmlstatemachine_p.h4
3 files changed, 32 insertions, 4 deletions
diff --git a/src/scxml/doc/qtscxml-instantiating-state-machines.qdoc b/src/scxml/doc/qtscxml-instantiating-state-machines.qdoc
index 0737dff..37cff10 100644
--- a/src/scxml/doc/qtscxml-instantiating-state-machines.qdoc
+++ b/src/scxml/doc/qtscxml-instantiating-state-machines.qdoc
@@ -146,8 +146,8 @@
\code
stateMachine->submitEvent("tap", QVariantMap({
- std::make_pair("artist", "Fatboy Slim"),
- std::make_pair("title", "The Rockafeller Skank")
+ { "artist", "Fatboy Slim" },
+ { "title", "The Rockafeller Skank" }
});
\endcode
diff --git a/src/scxml/qscxmlstatemachine.cpp b/src/scxml/qscxmlstatemachine.cpp
index e57630f..cc190fb 100644
--- a/src/scxml/qscxmlstatemachine.cpp
+++ b/src/scxml/qscxmlstatemachine.cpp
@@ -731,7 +731,9 @@ void QScxmlStateMachinePrivate::emitStateActive(int stateIndex, bool active)
{
Q_Q(QScxmlStateMachine);
void *args[] = { Q_NULLPTR, const_cast<void*>(reinterpret_cast<const void*>(&active)) };
- QMetaObject::activate(q, m_metaObject, stateIndex, args);
+ const int signalIndex = m_stateIndexToSignalIndex.value(stateIndex, -1);
+ if (signalIndex >= 0)
+ QMetaObject::activate(q, m_metaObject, signalIndex, args);
}
void QScxmlStateMachinePrivate::emitInvokedServicesChanged()
@@ -755,6 +757,26 @@ void QScxmlStateMachinePrivate::attach(QScxmlStateMachineInfo *info)
info, &QScxmlStateMachineInfo::transitionsTriggered);
}
+void QScxmlStateMachinePrivate::updateMetaCache()
+{
+ m_stateIndexToSignalIndex.clear();
+
+ if (!m_tableData)
+ return;
+
+ if (!m_stateTable)
+ return;
+
+ int signalIndex = 0;
+ for (int i = 0; i < m_stateTable->stateCount; ++i) {
+ const auto &s = m_stateTable->state(i);
+ if (!s.isHistoryState() && s.type != StateTable::State::Invalid) {
+ m_stateIndexToSignalIndex.insert(i, signalIndex);
+ ++signalIndex;
+ }
+ }
+}
+
QStringList QScxmlStateMachinePrivate::stateNames(const std::vector<int> &stateIndexes) const
{
QStringList names;
@@ -1767,6 +1789,8 @@ void QScxmlStateMachine::setTableData(QScxmlTableData *tableData)
== QScxmlExecutableContent::StateTable::terminator);
}
+ d->updateMetaCache();
+
emit tableDataChanged(tableData);
}
@@ -2174,7 +2198,7 @@ bool QScxmlStateMachine::isDispatchableTarget(const QString &target) const
if (target.startsWith(QStringLiteral("#_"))) {
QStringRef targetId = target.midRef(2);
for (auto invokedService : d->m_invokedServices) {
- if (invokedService.service->id() == targetId)
+ if (invokedService.service && invokedService.service->id() == targetId)
return true;
}
}
diff --git a/src/scxml/qscxmlstatemachine_p.h b/src/scxml/qscxmlstatemachine_p.h
index 129ef61..a2926a8 100644
--- a/src/scxml/qscxmlstatemachine_p.h
+++ b/src/scxml/qscxmlstatemachine_p.h
@@ -282,6 +282,8 @@ public:
void attach(QScxmlStateMachineInfo *info);
const OrderedSet &configuration() const { return m_configuration; }
+ void updateMetaCache();
+
private:
QStringList stateNames(const std::vector<int> &stateIndexes) const;
std::vector<int> historyStates(int stateIdx) const;
@@ -378,6 +380,8 @@ private:
bool isPaused() const { return m_runningState == Paused; }
QScxmlInternal::StateMachineInfoProxy *m_infoSignalProxy;
+
+ QHash<int, int> m_stateIndexToSignalIndex;
};
QT_END_NAMESPACE