[Qt-interest] QWaitCondition prevents signals from calling slots
Jonathan Wong
jhannwong at gmail.com
Sat May 23 01:48:34 CEST 2009
Yeah, I saw that, but that stuck to the back of my head and I couldn't see it for a while. :)
Thanks for pointing it out!
The docs didn't quite explain it like Thiago did. It did imply, though...
"If the signal is emitted from the thread in which the receiving object lives, the slot is invoked
directly, as with Qt::DirectConnection; otherwise the signal is queued, as with Qt::QueuedConnection."
But it is still partial info at best.
The experiments I did (inspired by Thiago) showed that Thiago's elegant explanation was spot on.
Slots are called via the thread the slots' object lives in. Blocking that thread will prevent
slots from "hearing" signals.
Signals are queued (assuming the most generic, works-in-cases mechanism) on some queue, waiting to
be taken up by slots' threads.
Though the docs did inspire the above theory/fact to be guessed at (and I guessed it when I first
saw signals/slots), the docs wasn't adequate there. So vague was the idea put forth, my conscious
mind couldn't bring itself to confidently accept my guesses. Hmm. I sound schizophrenic.
Lucas Artias wrote:
> On Tue, May 19, 2009 at 11:51 PM, Jonathan Wong <jhannwong at gmail.com
> <mailto:jhannwong at gmail.com>> wrote:
>
> Actually, further tests showed that a thread can both wait on a
> QWaitCondition and wait for
> incoming signals to its slots. But this thread must be a different
> one from the thread emitting
> the signals.
>
> I couldn't find any online docs explaining the relations between
> threads and signals. Couldn't
> find the word "thread" here:
> http://doc.trolltech.com/4.5/signalsandslots.html
>
>
> The documentation you want is at
> http://doc.trolltech.com/4.5/qt.html#ConnectionType-enum. This describes
> the different behaviors available when signals and threads interact.
>
> The default connection type is Qt:Autoconnect which behaves differently
> based on if you are send a signal to your own thread or to a different
> thread.
>
> Lucas
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list