[Qt-interest] QThread event loop running in main thread?
Scott Aron Bloom
Scott.Bloom at onshorecs.com
Tue Dec 28 22:35:53 CET 2010
On Tuesday, 28 de December de 2010 13:03:08 Mihail Naydenov wrote:
> > Using signals in a class derived from QThread isn't wrong. It's
> > just a concept
> >
> > violation. A signal called "workDone" means the job is done, not
> > that the thread is done. Otherwise, you could just use the
> > "finished" signal.
>
> I agree with "concept violation", still, if you know what are you
> doing,
> moveToThread(this) gives you
>
> the simples possible framework. That was the argument all about.
No.
I called:
signals - concept violation
slots - probably an error
moveToThread(this) - forbidden
Violating the encapsulation is a bad thing, but it's forgivable and, if
done right, can work. Using slots is probably wrong, because you usually
expect them to be run in the thread you started, when they don't.
moveToThread(this) is never right. It does more than what you think it
does.
------------
If someone is new to Qt, how would they know about this forbidden
method?
The docs (at least the 4.6.3 version) do not say ANYTHING about that in
the moveToThread documentation
Looking at (again the 4.6.3) code, I don't see a Q_ASSERT( targetThread
!= this ) to prevent the forbidden code..
Some simple documentation describing what you have put into email in
this thread, and an assertion here or there, would definitely clear
things up...
Otherwise, I expect this thread to come back up in about 3 months.. That
seems to be the average
Scott
More information about the Qt-interest-old
mailing list