[Qt-interest] Example of "moveToThread (this)" idiom -- legal?

K. Frank kfrank29.c at gmail.com
Sun Jan 2 20:51:22 CET 2011


Hello Thiago -

On Sun, Jan 2, 2011 at 2:22 PM, Thiago Macieira <thiago at kde.org> wrote:
> On Sunday, 2 de January de 2011 10:18:01 K. Frank wrote:
>> Hi Mihail -
>>
>> On Sun, Jan 2, 2011 at 6:01 AM, Mihail Naydenov <mlists at ymail.com> wrote:
>> > Without going through the example, I just wanted to remind you
>> >
>> > Qt itself uses moveToThred(this)
>> >
>> > (see QFilesystemWatcher implementation)
>>
>> Good point. It looks like it uses the full "moveToThread (this)"
>> idiom:  It derives from QThread, calls moveToThread (this),
>> and has signals ans slots.
>>
>> > So, I am sure by definition moveToThred(this) is not illegal.
>>
>> Yes, QFileSystemWatcher looks like a strong vote that
>> moveToThread (this) is technically legal.
>
> Remember the one big assumption here: that QFileSystemWatcher is properly
> written.
>
> It's not a given.

Well yes.  Of course it's not a given.  But it's also not a given that
if I write a program where I _don't_ derive from QThread it will be
properly written.

Two questions:

Is my example program properly written?

Are extra conditions (whatever that means) required for a
"moveToThread (this)"-style program to be properly written?
E.g., are there special requirements for consistency with
undocumented (and potentially changeable) internals of
QThread or other parts of the Qt framework?

> ...
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
>  Senior Product Manager - Nokia, Qt Development Frameworks

Thanks.


K. Frank



More information about the Qt-interest-old mailing list