Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.15
-
None
Description
If <assign> element location points to a valid array element, state machine generate 'error.execution' event
Minimal example
The example is classical foreach demo which successfully runs on USCXML or SCION.
Expected
Current result
Fails on Qt with the message:
DynamicStateMachine(0x44bf00, name = "ScxmlForeach") had error "error.execution" : "t_INPUTS[0] in assign instruction in transition of state 'configuration' with expr=\"_event.data.x\" does not exist"
#include <QCoreApplication> #include <QScxmlStateMachine> #include <QBuffer> #include <QLoggingCategory> namespace Scxml { static const char *chScxml = "<scxml datamodel=\"ecmascript\" name=\"ScxmlForeach\" version=\"1.0\" xmlns=\"http://www.w3.org/2005/07/scxml\">" " <datamodel>" " <data expr=\"[ 0, 0, 0 ]\" id=\"t_INPUTS\"/>" " </datamodel>" " <parallel id=\"p\">" " <transition event=\"error.*\" target=\"fail\"/>" " <state id=\"state_3\">" " <state id=\"state_3_off\">" " <transition cond=\"_event.data==1\" event=\"event.2\" target=\"state_3_on\"/>" " </state>" " <state id=\"state_3_on\">" " <transition cond=\"! (_event.data==1)\" event=\"event.2\" target=\"state_3_off\"/>" " </state>" " </state>" " <state id=\"state_2\">" " <state id=\"state_2_off\">" " <transition cond=\"_event.data==1\" event=\"event.1\" target=\"state_2_on\"/>" " </state>" " <state id=\"state_2_on\">" " <transition cond=\"! (_event.data==1)\" event=\"event.1\" target=\"state_2_off\"/>" " </state>" " </state>" " <state id=\"state_1\">" " <state id=\"state_1_off\">" " <transition cond=\"_event.data==1\" event=\"event.0\" target=\"state_1_on\"/>" " </state>" " <state id=\"state_1_on\">" " <transition cond=\"! (_event.data==1)\" event=\"event.0\" target=\"state_1_off\"/>" " </state>" " </state>" " <state id=\"inputs\">" " <state id=\"configuration\">" " <onentry>" " <foreach array=\"t_INPUTS\" index=\"varIndex\" item=\"varItem\">" " <send eventexpr=\"'event.' + varIndex\">" " <content expr=\"varItem\"/>" " </send>" " </foreach>" " </onentry>" " <transition event=\"change.inputs\" target=\"configuration\">" " <assign expr=\"_event.data.x\" location=\"t_INPUTS[0]\"/>" " <assign expr=\"_event.data.y\" location=\"t_INPUTS[1]\"/>" " <assign expr=\"_event.data.z\" location=\"t_INPUTS[2]\"/>" " </transition>" " </state>" " </state>" " </parallel>" " <final id=\"fail\"/>" "</scxml>"; } // end namespace: Scxml int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QBuffer buffer; buffer.open(QBuffer::ReadWrite); buffer.write(Scxml::chScxml); buffer.seek(0); QLoggingCategory::setFilterRules("qt.scxml.statemachine=true"); auto machine = QScxmlStateMachine::fromData(&buffer); machine->connectToState("fail",[](bool active){ if (active) { qCritical() << "I must not fail here!"; QCoreApplication::exit(-1); } }); machine->start(); QVariantMap data; data.insert("x", 1); data.insert("y", 1); data.insert("z", 1); machine->submitEvent("change.inputs", data); return a.exec(); }