diff options
author | Janne Anttila <janne.anttila@digia.com> | 2009-05-04 11:43:52 (GMT) |
---|---|---|
committer | Janne Anttila <janne.anttila@digia.com> | 2009-05-04 11:43:52 (GMT) |
commit | 1a0fd473bcea62d1e471bb49ca06d931d0deb616 (patch) | |
tree | d96b7bab0495432935c1b12b82ba87048652e31f /src/corelib/thread/qthread_unix.cpp | |
parent | 32493498dcf3aa1ab9973aab381c5ca99d9ba9fd (diff) | |
download | Qt-1a0fd473bcea62d1e471bb49ca06d931d0deb616.zip Qt-1a0fd473bcea62d1e471bb49ca06d931d0deb616.tar.gz Qt-1a0fd473bcea62d1e471bb49ca06d931d0deb616.tar.bz2 |
Fix for thread termination in Symbian OS.
Since Open C does not support all pthread funtions, thread termination
in Symbian OS is implemented differently. Before this fix,
QThread::Terminate just terminated the native thread. Because
QThreadPrivate::finish was not called, the 'running', 'finished' etc
flags were not set and thread termination related signals were not
correctly emitted.
In UNIX finish is called by pthread_cancel since thread cancelation
points are set. In Symbian OS we need to call it manually since
pthread_cancel is not supported.
It was necessary to add a new parameter to QThreadPrivate::finish, which
tells whether the native thread handle can be closed or not. This was
required since 'symbian_thread_handle.Terminate' will not succeed if
thread handle is closed. On the other hand we cannot first terminate the
thread and then call QThreadPrivate::finish.
Autotest: qthread and qprocess passes in HW (5800) and Emulator
Review By: miikka.heikkinen@digia.com
Diffstat (limited to 'src/corelib/thread/qthread_unix.cpp')
-rw-r--r-- | src/corelib/thread/qthread_unix.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index aad55bc..567c936 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -226,7 +226,7 @@ void *QThreadPrivate::start(void *arg) } #ifdef Q_OS_SYMBIAN -void QThreadPrivate::finish(void *arg, bool lockAnyway) +void QThreadPrivate::finish(void *arg, bool lockAnyway, bool closeNativeHandle) #else void QThreadPrivate::finish(void *arg) #endif @@ -258,7 +258,8 @@ void QThreadPrivate::finish(void *arg) d->thread_id = 0; #ifdef Q_OS_SYMBIAN - d->data->symbian_thread_handle.Close(); + if (closeNativeHandle) + d->data->symbian_thread_handle.Close(); #endif d->thread_done.wakeAll(); #ifdef Q_OS_SYMBIAN @@ -530,10 +531,11 @@ void QThread::terminate() d->terminatePending = true; return; } - - d->data->symbian_thread_handle.Terminate(KErrNone); - + d->terminated = true; + QThreadPrivate::finish(this, false, false); + d->data->symbian_thread_handle.Terminate(KErrNone); + d->data->symbian_thread_handle.Close(); #endif |