diff options
Diffstat (limited to 'src/scxml/qscxmlstatemachine.cpp')
-rw-r--r-- | src/scxml/qscxmlstatemachine.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/scxml/qscxmlstatemachine.cpp b/src/scxml/qscxmlstatemachine.cpp index 58832b8..b22c618 100644 --- a/src/scxml/qscxmlstatemachine.cpp +++ b/src/scxml/qscxmlstatemachine.cpp @@ -767,6 +767,9 @@ void QScxmlStateMachinePrivate::attach(QScxmlStateMachineInfo *info) void QScxmlStateMachinePrivate::updateMetaCache() { + // This function creates a mapping from state index/name to their signal indexes. + // The state index may differ from its signal index as we don't generate history + // and invalid states, effectively skipping them m_stateIndexToSignalIndex.clear(); m_stateNameToSignalIndex.clear(); @@ -2366,7 +2369,11 @@ void QScxmlStateMachine::stop() bool QScxmlStateMachine::isActive(int stateIndex) const { Q_D(const QScxmlStateMachine); - return d->m_configuration.contains(stateIndex); + // Here we need to find the actual internal state index that corresponds with the + // index of the compiled metaobject (which is same as its mapped signal index). + // See updateMetaCache() + const int mappedStateIndex = d->m_stateIndexToSignalIndex.key(stateIndex, -1); + return d->m_configuration.contains(mappedStateIndex); } QT_END_NAMESPACE |