From a3f97ba985c80b147bcc902416304544f1d0ec58 Mon Sep 17 00:00:00 2001 From: mread Date: Wed, 22 Jun 2011 11:39:23 +0100 Subject: QTBUG-17776, reporting terminated threads as not running on Symbian On Symbian app shutdown all threads are terminated and their stack memory is released, but there is no time for notification of exit of these threads. So any attempt to access stack data in such a thread from static data destruction will cause a crash. This was happening with the XmlQuery thread. It was testing if the thread was still running, and QThread thought it was because there was no notification. So when the XmlQuery thread was asked to exit, and QThread::exit tried to access a stack based QEventLoop, there was a crash. By adding a test if the thread has been terminated to QThread::isRunning(), clients can now rely on this to know that it is safe to call exit() on a thread. The existing code is made safe again. Task-number: QTBUG-17776 Reviewed-by: Shane Kearns --- src/corelib/thread/qthread.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/corelib/thread') diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index 2cdaca036c..2f96920161 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -431,6 +431,12 @@ bool QThread::isRunning() const { Q_D(const QThread); QMutexLocker locker(&d->mutex); +#ifdef Q_OS_SYMBIAN + // app shutdown on Symbian can terminate threads and invalidate their stacks without notification, + // check the thread is still alive. + if (d->data->symbian_thread_handle.Handle() && d->data->symbian_thread_handle.ExitType() != EExitPending) + return false; +#endif return d->running; } -- cgit v1.2.3