summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread
diff options
context:
space:
mode:
authormread <qt-info@nokia.com>2011-06-22 11:39:23 +0100
committermread <qt-info@nokia.com>2011-06-23 09:36:02 +0100
commita3f97ba985c80b147bcc902416304544f1d0ec58 (patch)
tree188bad286e82fa104bd7a51ffaf899ec0765baa3 /src/corelib/thread
parent18da8a264f9a155332940c9e7b416db0b0b5058d (diff)
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
Diffstat (limited to 'src/corelib/thread')
-rw-r--r--src/corelib/thread/qthread.cpp6
1 files changed, 6 insertions, 0 deletions
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;
}