[Qt-interest] QThread run() method

Rehan rehan at india.synfora.com
Mon Aug 31 13:17:03 CEST 2009


    Below code may resolve your issue.

 

    if (th->running())

    {

        th->terminate();

        th->wait();

    }

 

 

 

Regards,

Rehan

  _____  

From: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] On Behalf Of Sarvesh Saran
Sent: Monday, August 31, 2009 4:06 PM
To: qt-interest at trolltech.com
Subject: [Qt-interest] QThread run() method

 

Hi,

 

This question is a little naïve but I still need an answer to it.

 

What happens to  a QThread after the run method is done? The documentation
says the execution ends when you return from run. Does that mean the thread
object ceases to exists ? for some reason my thread manages to receive a
signal and execute a slot even after the run method is done .i.e.

 

Qthread *th = new Qthread();

th->start




..

And later when the thread has finished its run method..

 

th->sendStopSignal(); (thread is not running at this point, th->isRunning()
returns false)

delete th;

th=NULL;

 

(for some reason th receives this signal and executes the slot)

 

Thanks,

Sarvesh

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090831/818e508b/attachment.html 


More information about the Qt-interest-old mailing list