João Abecasis wrote: > Chris Meyer wrote: >> The documentation promotes the idea of using 'moveToThread' as a >> preferred threading mechanism. However, we've found that moveToThread >> is full of pitfalls. >> >> Particularly, an object must be deleted on the thread on which it >> resides. This makes it difficult to manage the lifetime of objects >> that have been moved to a thread via moveToThread. You need to >> configure an independent mechanism to delete objects that have been >> moved to thread (i.e. send a signal to the thread that it's about to >> shutdown and allow the objects to deleteLater within the thread, which >> also implies that you need to keep track of the objects that are >> within the thread, which somewhat defeats the apparent simplicity of >> moveToThread). Also, you cannot use the finished signal from the >> thread since the thread will already be gone by then. > > Since Qt 4.8 you can connect QThread::finished to QObject::deleteLater > and it should do the right thing in the appropriate thread.
For reference, here's a link to the commit implementing this: http://qt.gitorious.org/qt/qt/commit/0c643b179c5154c50b61dba421016b7b48794720 >> The bug will show up intermittently and differently on various >> platforms and is difficult to debug if you don't know about the >> problem. You'll just end up with spurious crashes (typically at quit >> time), especially for networking objects. Cheers, João _______________________________________________ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development