[Interest] Emitting a signal from a different thread than the object lives in
Konstantin Shegunov
kshegunov at gmail.com
Fri Aug 26 11:16:28 CEST 2016
On Fri, Aug 26, 2016 at 11:38 AM, Etienne Sandré-Chardonnal <
etienne.sandre at m4x.org> wrote:
> Thanks, does that mean that the moc-generated signal member function is
> made fully thread safe?
>
Not really, no. Qt checks the connection type and compares the thread from
which the signal is emitted to the thread affinity of the receiving object.
Assuming you're using auto connection, If the threads match your slot will
be executed immediately, if they don't Qt will post a deferred invocation
event in the receiver object's thread's event queue, which is the thread
safe. The implication is that you can emit signals from threads that don't
have a running event loop, but you can't have queued slot invocations for
objects that live in those threads, i.e. queued slot calls need an event
loop.
Kind regards.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160826/f7dbcd6c/attachment.html>
More information about the Interest
mailing list