[PATCH] wait for CompletionWorkerThread to exit before destroying it

Peter Oberndorfer kumbayo84 at arcor.de
Mon Dec 22 18:59:43 UTC 2008


On Sonntag 21 Dezember 2008, Nick Shaforostoff wrote:
> 2008/12/21 David Nolden <zwabel at googlemail.com>:
> > Am Sonntag, 21. Dezember 2008 11:49:17 schrieb Peter Oberndorfer:
> >> otherwise we get "QThread: Destroyed while thread is still running"
> >> warnings and crashes.
> >> ---
> >> I think QThread::quit/exit only tells the event loop to exit
> >> but it does not wait until the thread terminates.
> >>
> >> Attached is a trace of a crash that is probably caused by this.
> >
> > Applied, thanks
> 
> why not just use QObject::deleteLater() ?
> http://doc.trolltech.com/4.4/qobject.html#deleteLater

I just tried and it still crashes.

deleteLater() deletes the object when the own event loop is entered.
But i think there is no guarantee that the other event loop/thread has finished,
before the own event loop deletes the object.

To make the race more likely i added a sleep(5) in
CodeCompletionWorker::run()
directly after exec()

Greetings Peter






More information about the KDevelop-devel mailing list