[Interest] Emitting a signal from a different thread than the object lives in

Konstantin Shegunov kshegunov at gmail.com
Fri Aug 26 11:22:53 CEST 2016


On Fri, Aug 26, 2016 at 12:11 PM, Reinhardt Behm <rbehm at hushmail.com> wrote:
>
> Your signal belongs to your QThread derived object. This does not live in
> the
> thread started with run().


This is inconsequential. The only thing that matters is the thread from
which the signal was emitted, not in which object it was declared. In
general, threads don't care about objects, they only care about the call
stack (i.e. the called function), so you can have different methods called
from different threads on the same object. Qt makes this mess a bit clear
by introducing the thread affinity for QObject instances, but again this
doesn't prevent calls from different threads to occur for the same object's
methods. In the end, the methods are in the static part of the binary, and
they're oblivious about the underlying data (the object) until the actual
call is made; the this pointer is "injected" by the compiler (usually as
first argument when opening the stack frame) when generating C++ binaries
under the hood.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160826/d035229c/attachment.html>


More information about the Interest mailing list