Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Queued signals / slots help
Forum Update on Monday, May 27th 2025

Queued signals / slots help

Scheduled Pinned Locked Moved Mobile and Embedded
10 Posts 4 Posters 8.2k 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.
  • S Offline
    S Offline
    SteveKing
    wrote on last edited by
    #1

    Hi,

    I'm trying to debug a problem where I'm using signals/slots to send data from the UI thread to a worker and back again. This works fine on a PC, but on an embedded system it occasionally locks up (no slots called in the worker thread) until the application is minimised and then it starts again. My guess is that I'm sending events faster than they can be processed and am filling up something somewhere.

    I can't actually debug on the target, but I was wondering if there's a way of seeing the content of the queued signals, and also seeing if a threads event loop is running. One thing I do know is that the UI event loop is still working and the emit calls are also working.

    Sorry for being a bit vague, but any ideas?

    Thanks,
    Steve

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      It is always a good idea to limit the communication between threads to a minimum. That will improve performance and reduce the chance of deadlocks. Perhaps you should re-evaluate if you really need the amount of messages you send between the threads. Since you're talking about the GUI, do you really need more than, say, 25 messages per second tops?

      It is quite easy to swamp the message queues with queued signals and slots.

      1 Reply Last reply
      0
      • B Offline
        B Offline
        blex
        wrote on last edited by
        #3

        [quote author="SteveKing" date="1291379962"]and also seeing if a threads event loop is running[/quote]

        Use QTimer and debug message on timer.


        Oleksiy Balabay

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SteveKing
          wrote on last edited by
          #4

          Andre: We should only be doing updates every second, but I've just found an infinte loop where one call is emit'ing everytime it receives a notification so that could result in more updates. What happens when the queue is swamped? Is there a maximum length beyond which events are dropped or does the queue keep growing?

          Blex: Thanks for that, I'll give that a go.

          Steve

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on last edited by
            #5

            AFAIK, what happens is that also other events in the queue start to get delayed: redraws, mouse events, keyboard events, timers, network handling... That could really damage the performance of your app.

            I don't know if eventually events will be dropped, or that the queue simply grows on untill you run out of memory, but you probably don't want to experience it either way.

            1 Reply Last reply
            0
            • G Offline
              G Offline
              GordonSchumacher
              wrote on last edited by
              #6

              Make sure you are not getting into a UI update loop; if you've overloaded the event functions, pay special attention there.

              processEvents() is often evil, because it can result in (pseudo-)recursion. Beware, beware!

              Try using QSignalSpy for your debugging - that will let you hook particular signals, but not globally.

              1 Reply Last reply
              0
              • G Offline
                G Offline
                GordonSchumacher
                wrote on last edited by
                #7

                Oh! For that matter...

                If you're using GCC (on any platform), there's a neat hack you can use... there's a function called __cyg_profile_func_enter (and a matching _exit) which, if you pass -finstrument-functions to GCC, wil be called at the beginning and end of every function compiled with that switch.

                There's a great summary and little "library" that got "posted to Linux Gazette,":http://linuxgazette.net/151/melinte.html called CTrace. I've used it before, and while it may not trace Qt signals, it may show you where you're stuck.

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  andre
                  wrote on last edited by
                  #8

                  Neat tip!

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SteveKing
                    wrote on last edited by
                    #9

                    Hi,

                    Thanks for the tips. I think it's time for some instrumentation...

                    Regards,
                    Steve

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SteveKing
                      wrote on last edited by
                      #10

                      Well after some quick learning about QSignalSpy (which is very neat!) I've managed to instrument everything and there's something weird going on... It seems that the worker thread stops processing signals/slots at some point during the run, nothing is blocking in the thread as far as I can tell and if the worker thread has a simple QTimer in it the signals keep being processed! I think it's an underlying WinCE problem but it's very odd!

                      Anyway, thanks for the help above.

                      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