diff options
author | mread <qt-info@nokia.com> | 2011-06-22 10:39:23 (GMT) |
---|---|---|
committer | mread <qt-info@nokia.com> | 2011-06-23 08:36:02 (GMT) |
commit | a3f97ba985c80b147bcc902416304544f1d0ec58 (patch) | |
tree | 188bad286e82fa104bd7a51ffaf899ec0765baa3 /src | |
parent | 18da8a264f9a155332940c9e7b416db0b0b5058d (diff) | |
download | Qt-a3f97ba985c80b147bcc902416304544f1d0ec58.zip Qt-a3f97ba985c80b147bcc902416304544f1d0ec58.tar.gz Qt-a3f97ba985c80b147bcc902416304544f1d0ec58.tar.bz2 |
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')
-rw-r--r-- | src/corelib/thread/qthread.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index 2cdaca0..2f96920 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; } |