Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Removing transitions from a QState causes crash
Qt 6.11 is out! See what's new in the release blog

Removing transitions from a QState causes crash

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 1.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    alasdairhatfield
    wrote on last edited by
    #1

    Hi,

    I add two transitions to the state and build up a list of states thus:

    @ Transitions.append(WelcomeState->addTransition(HelpSignalMapper, SIGNAL(mapped(QString)), HelpState));
    Transitions.append(WelcomeState->addTransition(GuiSignalMapper, SIGNAL(mapped(QString)), BasicProdState));
    @

    This works and on running the code, the transitions occur.
    Later I want to remove the states but all attempts cause the application to crash, not at the point I remove the transitions but a couple of lines later. (If I comment out the code removing the states then the rest of the application continues to run ok)

    I have tried two methods to remove the transitions but the result is the same:

    Either using the list I built up myself:

    @ while (!Transitions.isEmpty()) {
    WelcomeState->removeTransition(Transitions.takeFirst());
    }@

    Or using the transitions() method to gain the list of transitions:

    @ QList<QAbstractTransition*> transitions = WelcomeState->transitions();
    while (!transitions.isEmpty()) {
    WelcomeState->removeTransition(transitions.takeFirst());
    }@

    Any ideas as I can't see what I am doing wrong.

    Thanks

    1 Reply Last reply
    0
    • C Offline
      C Offline
      codenode
      wrote on last edited by
      #2

      Have you tried to debug this code?
      Is WelcomeState still a valid pointer?

      1 Reply Last reply
      0
      • A Offline
        A Offline
        alasdairhatfield
        wrote on last edited by
        #3

        Have checked again just to be sure.
        WelcomeState gets a value in the constructor

        @
        WelcomeState = new QState();
        @

        and this is the same when I reach

        @
        QList<QAbstractTransition*> transitions = WelcomeState->transitions();
        @

        1 Reply Last reply
        0
        • N Offline
          N Offline
          niko
          wrote on last edited by
          #4

          Hi,

          I just checked that. For me, it works, when I do the remove-thing in the state you are reaching.

          For example, when you have 3 transitions in state A and you go from state A to state B, you can remove the transitions from state A in state B.

          Hope it helps.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved