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

QHistoryState supports only one initial state



    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.6.0 Beta
    • 5.4.2, 5.5.0 Beta
    • Core: State Machine
    • None
    • 5fd9fe02ff14438a2d0c93789be138a58583dbe8


      Consider the following state machine:

      parallel state
          history state, initial transition: a2, b1
          state a
              state a1
              state a2
          state b
              state b1

      When the parallel state is entered for the first time, the resulting configuration should be (a2,b1). This is because there is no previous history, so the history state will take the initial transition (instead of restoring the previously stored state). However, QHistoryState only supports a single initial state.

      A work-around would be to add a state (let's call it "c") with an unconditional transition to a2 and b1. However, this state needs to be added to the parent state of the history state, which results in an infinite loop in this case: when the transition is taken, it exits a sub-state of the parallel state, which exits the parallel state, which in turn saves the history. Then it enters a2 (which implicitly enters a, which in turn enters the parallel state). By entering the parallel state, it checks the history state, which sees that there is a saved history including "c", so it restores that. Now "c" has an unconditional transition, so we start all over again. Conclusion: this does not work.

      The proper fix is to have QHistoryState only handle initial transitions, and "simulate" the current initial state by setting it as the target for that initial transition.


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



            erikv Erik Verbruggen
            erikv Erik Verbruggen
            0 Vote for this issue
            1 Start watching this issue



              Gerrit Reviews

                There are no open Gerrit changes