[Interest] moveToThread used in constructor to move "this"

Prav pr12og2 at programist.ru
Thu Feb 25 11:32:15 CET 2016


> Would it be possible to circumvent this issue by moving the thread
> object onto its own thread too?
>     Foo() : QObject(nullptr) {
>        moveToThread(&m_thread);
>        m_thread->moveToThread(m_thread);
>        m_thread.start();
>     }
> Looks like the much debated move-QThread-onto-its-own-thread
> antipattern, but it's not the same obviously.

Do you see any help of that action?
And  how  destructor will look like?
If it will be as it was before ... this mean
that  m_thread  thread  will  call  its  quit() function and
I did not get
who  after  that  would  release memory allocated to Foo?


PS
you probably ment to write "." instead of "->":
  m_thread.moveToThread(m_thread);
is not it?




More information about the Interest mailing list