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

QHistoryState supports only one initial state

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3: Somewhat important
    • Resolution: Done
    • Affects Version/s: 5.4.2, 5.5.0 Beta
    • Fix Version/s: 5.6.0 Beta
    • Component/s: Core: State Machine
    • Labels:
      None
    • Commits:
      5fd9fe02ff14438a2d0c93789be138a58583dbe8

      Description

      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.

        Attachments

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

          Activity

            People

            Assignee:
            erikv Erik Verbruggen
            Reporter:
            erikv Erik Verbruggen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes