Yes,

Api doc says:

Warning: This function is dangerous and its use is discouraged. The thread can 
be terminated at any point in its code path. Threads can be terminated while 
modifying data. There is no chance for the thread to clean up after itself, 
unlock any held mutexes, etc. In short, use this function only if absolutely 
necessary.

 

 

 

 

-----邮件原件-----
发件人: [email protected] 
[mailto:[email protected]] 代表 Thiago 
Macieira
发送时间: 2013年3月15日 1:51
收件人: [email protected]
主题: Re: [Interest] moveToThread and object deletion

 

On quinta-feira, 14 de março de 2013 18.33.38, Etienne Sandré-Chardonnal 

wrote:

> Is it safe and correct to connect QThread::quit() and QThread::terminated()

> to Worker::deleteLater() ? I would say no, as signal/slot mechanism will

> try to run deleteLater() in the workerThread, which is not running anymore,

> so object deletion will never happen.

 

That's actually very good thinking, showing you understand how threads work.

 

But we added a little bit of magic to the event dispatcher: after the 

finished() signal is emitted, it runs all events once again to process object 

deletions. You couldn't have known that by simple analysis.

 

In other words, you can connect finished() to deleteLater() and it will work.

-- 

Thiago Macieira - thiago.macieira (AT) intel.com

  Software Architect - Intel Open Source Technology Center

_______________________________________________
Interest mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to