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. QSpinBox::valueChanged with debugger breakpoint brain-damaged
Forum Updated to NodeBB v4.3 + New Features

QSpinBox::valueChanged with debugger breakpoint brain-damaged

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 634 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.
  • JonBJ Offline
    JonBJ Offline
    JonB
    wrote on last edited by JonB
    #1

    Ubuntu 19.04, Qt 5.12.2 as supplied with Ubuntu, Qt Creator 4.8.1, gdb 8.2.91.

    I have spent over a day on the most unbelievable frustration, and I want my money back :@

    connect(ui->spinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &MainWindow::spinBoxValueChanged);
    
    void MainWindow::spinBoxValueChanged(int number)
    {
    }
    

    That's it. Run suitable, and click the up-arrow to increment the number. All is well....

    ...Put a breakpoint on the { or } line in spinBoxValueChanged(). Just that. Now, when you increment it hits the breakpoint. Continue. spinBoxValueChanged() gets called a second time (after first spinBoxValueChanged() has exited, with the same stack trace as first time) , with number 1 higher than before. So for every click spin box number is increased by 2 if you hit a breakpoint (but only by 1 if you remove/disable the breakpoint)!! :@:@

    Spent a day till I realized it is hitting any breakpoint anywhere when within valueChanged() or anything it calls which causes the second call behaviour. Only now that my code is sorted so I don't need to break can I actually get on, but if I ever need to break again in something it calls I will be back to bad behaviour.

    Anyone able to repro in similar/different environment? I would like to know wth is going on?

    1 Reply Last reply
    0
    • Christian EhrlicherC Christian Ehrlicher

      The problem is the click timer of QSpinBox. There is also a bug report about this in the bugtracker: https://bugreports.qt.io/browse/QTBUG-14259

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #5

      @Christian-Ehrlicher said in QSpinBox::valueChanged with debugger breakpoint brain-damaged:

      The problem is the click timer of QSpinBox. There is also a bug report about this in the bugtracker: https://bugreports.qt.io/browse/QTBUG-14259

      @Christian-Ehrlicher is a genius/life-saver! He also advised a workaround:

      connect(ui->spinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &MainWindow::spinBoxValueChanged, Qt::QueuedConnection);
      

      I don't know if it is always suitable, but specifying Qt::QueuedConnection for any QSpinBox::valueChanged connection makes it work for me whether I have any breakpoint or not, so I thought others would like to know.

      Thanks @Christian-Ehrlicher !

      1 Reply Last reply
      0
      • gde23G Offline
        gde23G Offline
        gde23
        wrote on last edited by
        #2

        First a question: Why do yo overload the signal? The slot and signal both use int arguments so just connect it like this (or the new connect style)

        connect(ui->spinBox, SIGNAL(valueChanged(int), this, SLOT(spinBoxValueChanged(int));
        

        The behavior with the breakpoint really seems strange. It seems like something is broken with you gdb maybe? Do you get similar strange behavior with other code or only at that specific line?

        JonBJ 1 Reply Last reply
        0
        • gde23G gde23

          First a question: Why do yo overload the signal? The slot and signal both use int arguments so just connect it like this (or the new connect style)

          connect(ui->spinBox, SIGNAL(valueChanged(int), this, SLOT(spinBoxValueChanged(int));
          

          The behavior with the breakpoint really seems strange. It seems like something is broken with you gdb maybe? Do you get similar strange behavior with other code or only at that specific line?

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #3

          @gde23 said in QSpinBox::valueChanged with debugger breakpoint brain-damaged:

          Why do yo overload the signal? The slot and signal both use int arguments so just connect it like this (or the new connect style)

          I do not understand what you mean. What I have written precisely is how you do it with "or the new connect style"..., and is exactly the "new style" equivalent of what you suggest, how else do you think it should be? Unless you or someone else say otherwise...? See the example at https://doc.qt.io/qt-5/qspinbox.html#valueChanged. Just to keep you happy, I changed over to your old style, and naturally it behaves identically: increment by 1 when no breakpoint, hit & incremented twice if I put in a breakpoint.

          gdb will not be "broken", and I don't think it will be to do with gdb per se. No, I have used gdb/Creator etc. everything is fine, just this one case. Hence my question & frustration! And why I'd like someone to explain how it can lead to the behaviour I see?

          1 Reply Last reply
          0
          • Christian EhrlicherC Online
            Christian EhrlicherC Online
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #4

            The problem is the click timer of QSpinBox. There is also a bug report about this in the bugtracker: https://bugreports.qt.io/browse/QTBUG-14259

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            JonBJ 1 Reply Last reply
            1
            • Christian EhrlicherC Christian Ehrlicher

              The problem is the click timer of QSpinBox. There is also a bug report about this in the bugtracker: https://bugreports.qt.io/browse/QTBUG-14259

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #5

              @Christian-Ehrlicher said in QSpinBox::valueChanged with debugger breakpoint brain-damaged:

              The problem is the click timer of QSpinBox. There is also a bug report about this in the bugtracker: https://bugreports.qt.io/browse/QTBUG-14259

              @Christian-Ehrlicher is a genius/life-saver! He also advised a workaround:

              connect(ui->spinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &MainWindow::spinBoxValueChanged, Qt::QueuedConnection);
              

              I don't know if it is always suitable, but specifying Qt::QueuedConnection for any QSpinBox::valueChanged connection makes it work for me whether I have any breakpoint or not, so I thought others would like to know.

              Thanks @Christian-Ehrlicher !

              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