[Interest] Is it OK to emit from different thread?
Alexander Dyagilev
alervdvcw at gmail.com
Fri Nov 30 20:46:45 CET 2018
On 11/30/2018 10:15 PM, Jérôme Godbout wrote:
> The fact that QObject belong to Thread A and a method is used into Thread B should raise a flag, each QObject belong to a QThread and they should be used by that QThread only. You should move the Object to the other thread or use a signals / slots to communicate between thread.
Well, I always do so. But this object is a special case. It's not used
by other threads. It uses threads to perform various asynchronous tasks
using lambdas, called from these threads, and these lambdas are supposed
to return some result to it.
> You will have many problems the way you describe it,
No, I will not in this particular case :)
> the fact that the thread B is launching the signal of Object that belong on Thread A, the automatic connection will check the ownership of the object emiting the signal to queue or not the signal and this will be wrong since the related thread is not the current thread.
Hmm... I.e. if both A and B objects belongs to the same thread and slot
of A is connected to signal of B, then if signal of B is issued from
another thread, then slot of A will be called in this different thread,
not the thread A belongs to? OK, thanks.
> Note: inheriting QThread is wrong practice and should probably never be done.
Yep, I know.
More information about the Interest
mailing list