Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
4.8.4, 5.0.0
-
None
Description
Code below hangs:
QStateMachine machine; QState* parallel = new QState(QState::ParallelStates, &machine); machine.setInitialState(parallel); QFinalState* final = new QFinalState(&machine); parallel->addTransition(parallel, SIGNAL(finished()), final); machine.start(); QCoreApplication::processEvents(); QState* group = new QState(parallel); QState* s1 = new QState(group); group->setInitialState(s1); QFinalState* done = new QFinalState(group); s1->addTransition(s1, SIGNAL(entered()), done); QEventLoop loop; connect(&machine, SIGNAL(finished()), &loop, SLOT(quit())); machine.start(); loop.exec();
It works fine without first machine.start().
Reason: When using parallel states it is possible to enter multiple states at the same time. The group initial state is entered when the the parallel state is entered. This works when the group is added before the machine is started.
But when the machine already runs the group initial state is not entered and there is no way to achieve this via the API.