Important: Please read the Qt Code of Conduct -

Signals / slots : Queued connection

  • Hi everyone,

    We have a software that makes an heavy duty of signals/slots in queued connection.
    After the software run OK for some hours, we can note some "freezes" of the main thread which manages the Ui. After it, it crashes without any known reasons...

    We have around 60 different threads that emit and receive signals from/to Ui thread.

    Does the heavy duty of Queued connection signals/slots between a lot of threads and the Ui thread could produce some stability issues ?

    Thanks by advance,

  • Well, it shouldn't. But if the main thread cannot process the signals as fast as they are added to the queue, the queue will keep on growing. I'm not sure what happens if the signal queue runs out of space. Might be that the other thread will simply be blocked until it can append the signal to the queue, might be that signal is discarded (unlikely) or might be that you just get an "out of memory" error (resulting in the crash subsequently).

    But it could also be that you simply make something wrong with event processing in your main thread. For example, the use of processEvent() can easily lead to stack overflows, if not used with extreme care. But in any case you should make a Debug build an check where exactly it crashes!


    BTW: What about adding a separate "manager" thread, that receives and handles all the signals from the "worker" threads and only emits a signal to the "main" thread when absolutely necessary?

  • First, thank you very much for your response !

    About adding a separate “manager” thread, i think it is a good idea. It should narrow the Ui thread work. I will try.

Log in to reply