[Qt-interest] QThread deletion

Jonathan Wong jhannwong at gmail.com
Sat Jun 6 16:25:07 CEST 2009


Though it is good practice to delete unused objects explicitly. Forces us to be mindful of what
resources we grabbed. Old school memory management, but it's safe school. And the practice ports
across to conventional C/C++ programming (without the benefit of QObject).

Wait a sec. I thought you need to call quit() or exit() to get the QThread out of its event loop?

Chandru... wrote:
> 
> wait() is enough ...
>   The thread associated with this QThread <qthread.html> object has
> finished execution (i.e. when it returns from run <qthread.html#run>()).
> This function will return true if the thread has finished. It also
> returns true if the thread has not been started yet.
> 
> 
> 2009/6/6 Patric <userqt at gmail.com <mailto:userqt at gmail.com>>
> 
>     Hi all,
>     one little question. Lets say I have a thread with event loop. Do I
>     have to call quit before I delete the thread object ?
>     For example, i think to do something like that :
>     Destructor{
>         MyThread::wait();
>         delete myThreadObject;
>     }
>      
>     But is "quit()" necessary here ? I think not, but I'm not sure.
>      
>     Patric
> 
> 
>     __________ Information from ESET NOD32 Antivirus, version of virus
>     signature database 4098 (20090522) __________
> 
>     The message was checked by ESET NOD32 Antivirus.
> 
>     http://www.eset.com
> 
>     _______________________________________________
>     Qt-interest mailing list
>     Qt-interest at trolltech.com <mailto:Qt-interest at trolltech.com>
>     http://lists.trolltech.com/mailman/listinfo/qt-interest
> 
> 
> 
> 
> -- 
> WAGMARE
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list