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

REG 4.8.6->5.4.1 QHistoryState - History not restored on self-transition to containing state

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.4.1
    • Core: State Machine
    • None

    Description

      The following state machine has got a signal GoToOuterStateHistory which makes the state machine leaving outer state and immediately re-enter outer state and it's sub-state history state. After that transition the state machine should be in the same sub-state it was when leaving outer state. But when taking the transition the first time, it is in history state's default state. The next time, when leaving from state 1, it goes to state 2 and when leaving from state 2 it goes to state 1.

      Bar.c++
      	m_StateMachine = new QStateMachine(this);
      	QState* OuterState = new QState(m_StateMachine);
      	OuterState->setObjectName("OuterState");
      
      	QState* State1 = new QState(OuterState);
      	State1->setObjectName("State1");
      	QState* State2 = new QState(OuterState);
      	State2->setObjectName("State2");
      
      	QHistoryState* HistoryState = new QHistoryState(OuterState);
      	HistoryState->setObjectName("History");
      
      	m_StateMachine->setInitialState(OuterState);
      	OuterState->setInitialState(State1);
      	HistoryState->setDefaultState(State1);
      
      	State1->addTransition(ui.switchInnerStates, SIGNAL(clicked()), State2);
      	State2->addTransition(ui.switchInnerStates, SIGNAL(clicked()), State1);
      	OuterState->addTransition(ui.goToOuterStateHistoryButton, SIGNAL(clicked()), HistoryState);
      

      State recovery by history state works fine when I replace the self-transition to outer state by temporarily entering a dummy state:

      Bar.c++
      	m_StateMachine = new QStateMachine(this);
      	QState* OuterState = new QState(m_StateMachine);
      	OuterState->setObjectName("OuterState");
      
      	QState* State1 = new QState(OuterState);
      	State1->setObjectName("State1");
      	QState* State2 = new QState(OuterState);
      	State2->setObjectName("State2");
      
      	QState* OuterDummyState = new QState(m_StateMachine);
      	OuterDummyState->setObjectName("OuterDummyState");
      
      	QHistoryState* HistoryState = new QHistoryState(OuterState);
      	HistoryState->setObjectName("History");
      
      	m_StateMachine->setInitialState(OuterState);
      	OuterState->setInitialState(State1);
      	HistoryState->setDefaultState(State1);
      
      	State1->addTransition(ui.switchInnerStates, SIGNAL(clicked()), State2);
      	State2->addTransition(ui.switchInnerStates, SIGNAL(clicked()), State1);
      	OuterState->addTransition(ui.goToOuterStateHistoryButton, SIGNAL(clicked()), OuterDummyState);
      	OuterDummyState->addTransition(OuterDummyState, SIGNAL(entered()), HistoryState);
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            Nico Bellic Jonny Erdmann
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: