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. StatusBar::showMessage causes max processor load - report bug/patch qt?
QtWS25 Last Chance

StatusBar::showMessage causes max processor load - report bug/patch qt?

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 3.6k Views
  • 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.
  • D Offline
    D Offline
    DerManu
    wrote on last edited by
    #1

    Hi there,
    observe:
    @ ui->statusBar->showMessage("hello", 4000);
    ui->statusBar->showMessage("", 1);@

    Now start top or htop. Funny eh? One core is busy performing an infinite loop (while the gui stays responsive).
    I came across this behaviour when I was too lazy to implement an additional "clearMessage" signal in a class that needs to communicate with the statusBar. So I figured I'd be damn smart and just let it show an empty message with timeout 1 (millisecond), so it'll properly clear right at the next event loop cycle. It bit me.

    I've looked at "qstatusbar.cpp":http://qt.gitorious.org/qt/qt/blobs/4.8/src/gui/widgets/qstatusbar.cpp#line595, and the problem's source is that they're handling the timeout really strange. They have a QTimer member (d->timer) which is created and deleted when showMessage/clearMessage is called. The timer timeout signal is connected to clearMessage. The problem is, that when you set an empty string, while another non-empty string is still in its showing interval, the timer never gets deleted. Because clearMessage immediately returns when the string is empty - without even checking whether there's a timer to delete. So basically you've got this rabid 1ms-timer having a party in the event loop.

    Now: Would you consider this a Qt bug or is it my fault for „misusing showMessage“ (although the docs don't warn me)? If so, is it any use reporting this? I mean I'm sure there are thousands of reports waiting to get fixed. On the other hand all you'd need is to either not only check whether the string is empty, but also whether the d->timer is 0. Or just d->timer->setSingleShot(true). Or better yet, quit this nonsense d->timer business, and just call QTimer::singleShot(timeout, this, SLOT (clearMessage())) in showMessage.
    Further, do I need a gitorious account to report a bug or even submit a patch or is there a way to do it anonymously (with proper patch inspection before applying it, obviously, but that should happen anyway)?

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lgeyer
      wrote on last edited by
      #2

      Please "report":http://qt-project.org/wiki/ReportingBugsInQt, this clearly looks like a bug to me. Don't forget to link the bug report here (and this thread in the bug report).

      If you already have a solution attach it to the bug report or "contribute":http://wiki.qt-project.org/Code_Reviews directly.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DerManu
        wrote on last edited by
        #3

        There it is:
        https://bugreports.qt-project.org/browse/QTBUG-24948

        Looked into getting a setup ready for contributing but they're certainly not interested in making it easy for new contributers, so I just posted the diff in the bugreport. Let's see what happens.

        1 Reply Last reply
        0
        • JeroentjehomeJ Offline
          JeroentjehomeJ Offline
          Jeroentjehome
          wrote on last edited by
          #4

          Well guys, saying this is a bug is a bit strong. The program doesn't crash and why would anyone setup a empty message in the status bar. I must admit it doesn't look good and they should protect it better. On the other hand you should have used 0 as the timeout. That would clear the statusbar instantly without a timeout.

          Greetz, Jeroen

          1 Reply Last reply
          0
          • D Offline
            D Offline
            DerManu
            wrote on last edited by
            #5

            Still, it's unintended behaviour with potentially really bad consequences. And as you can see, there's at least one guy that triggered it ;).
            If I hadn't noticed it right away, but a week in the future (100% cpu load isn't that obvious on a quadcore, but what would a client with a singlecore experience?) it would have been very tough to trace, since even valgrind profiling couldn't pinpoint it, just showing the QApplication::exec() as the trouble function.

            1 Reply Last reply
            0
            • L Offline
              L Offline
              lgeyer
              wrote on last edited by
              #6

              [quote author="Jeroentje@home" date="1332615747"]Well guys, saying this is a bug is a bit strong. The program doesn't crash and why would anyone setup a empty message in the status bar. I must admit it doesn't look good and they should protect it better. On the other hand you should have used 0 as the timeout. That would clear the statusbar instantly without a timeout.
              [/quote]

              Everything that does not work as intended is a bug - and this cleary does not work as intended.

              1 Reply Last reply
              0
              • R Offline
                R Offline
                rich
                wrote on last edited by
                #7

                [quote author="DerManu" date="1332520217"]There it is:
                https://bugreports.qt-project.org/browse/QTBUG-24948

                Looked into getting a setup ready for contributing but they're certainly not interested in making it easy for new contributers, so I just posted the diff in the bugreport. Let's see what happens.[/quote]

                Actually, getting set up as a contributor is pretty simple, and there's lots of docs on the wiki at http://wiki.qt-project.org/ your diff in the bug tracker cannot be used since unlike the gerrit system used for contributions, it doesn't ensure you've agreed to the contributor agreement etc.

                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