Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-28946

QStateMachine: adding parallel states to running machine fails

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 4.8.4, 5.0.0
    • Core: State Machine
    • 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.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            syntheticpp Peter Kümmel
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes