[Interest] moveToThread used in constructor to move "this"
Thiago Macieira
thiago.macieira at intel.com
Wed Feb 24 18:23:11 CET 2016
On quarta-feira, 24 de fevereiro de 2016 10:22:18 PST Lorenz Haas wrote:
> Foo() : QObject(nullptr) {
> moveToThread(&m_thread);
> m_thread.start();
> }
>
> ~Foo() {
> m_thread.quit();
> m_thread.wait();
> }
This destructor is either never run or deadlocks.
A QObject can only be destroyed in its thread of affinity. So the above is
running in that m_thread thread, which means it hasn't exited. Waiting for it
to exit will wait forever.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
More information about the Interest
mailing list