diff options
author | mread <qt-info@nokia.com> | 2012-01-04 15:19:49 (GMT) |
---|---|---|
committer | mread <qt-info@nokia.com> | 2012-01-04 15:40:15 (GMT) |
commit | 2997b89e6480abfed356fbd6fe248bc6d2accbe2 (patch) | |
tree | 8335038e9e26480a44902a6a55565e459ee4ce74 /src/corelib/thread | |
parent | dfe97e359443671f0cea9cddbe2ba0eccbaf48ce (diff) | |
download | Qt-2997b89e6480abfed356fbd6fe248bc6d2accbe2.zip Qt-2997b89e6480abfed356fbd6fe248bc6d2accbe2.tar.gz Qt-2997b89e6480abfed356fbd6fe248bc6d2accbe2.tar.bz2 |
QThreads on Symbian are named to allow them to be opened externally
The Qt 4.7 implementation of QThread on Symbian used libpthread. This
automatically generated a random name for a thread. The Qt 4.8
implmentation was leaving threads unnamed. This is a change in
behaviour, in that unnamed/anonymous threads cannot be opened outside
of the owning process. This was causing a bug in some client/server
situations.
The fix is to generate a name for the RThread underlying the QThread
as follows:
QThread object name + QThread object address + random number
Task-number: ou1cimx1#959586
Reviewed-by: Shane Kearns
Diffstat (limited to 'src/corelib/thread')
-rw-r--r-- | src/corelib/thread/qthread_symbian.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/corelib/thread/qthread_symbian.cpp b/src/corelib/thread/qthread_symbian.cpp index 2ea1b44..78bb293 100644 --- a/src/corelib/thread/qthread_symbian.cpp +++ b/src/corelib/thread/qthread_symbian.cpp @@ -46,10 +46,12 @@ #include "qthreadstorage.h" #include "qthread_p.h" #include <private/qsystemerror_p.h> +#include <private/qcore_symbian_p.h> #include <sched.h> #include <hal.h> #include <hal_data.h> +#include <e32math.h> // You only find these enumerations on Symbian^3 onwards, so we need to provide our own // to remain compatible with older releases. They won't be called by pre-Sym^3 SDKs. @@ -509,7 +511,21 @@ void QThread::start(Priority priority) // operations like file I/O fail, so we increase it by default. d->stackSize = 0x14000; // Maximum stack size on Symbian. - int code = d->data->symbian_thread_handle.Create(KNullDesC, (TThreadFunction) QThreadPrivate::start, d->stackSize, NULL, this); + int code = KErrAlreadyExists; + QString objName = objectName(); + TPtrC objNamePtr(qt_QString2TPtrC(objName)); + TName name; + objNamePtr.Set(objNamePtr.Left(qMin(objNamePtr.Length(), name.MaxLength() - 16))); + const int MaxRetries = 10; + for (int i=0; i<MaxRetries && code == KErrAlreadyExists; i++) { + // generate a thread name using a similar method to libpthread in Symbian + // a named thread can be opened from another process + name.Zero(); + name.Append(objNamePtr); + name.AppendNumFixedWidth(int(this), EHex, 8); + name.AppendNumFixedWidth(Math::Random(), EHex, 8); + code = d->data->symbian_thread_handle.Create(name, (TThreadFunction) QThreadPrivate::start, d->stackSize, NULL, this); + } if (code == KErrNone) { d->thread_id = d->data->symbian_thread_handle.Id(); TThreadPriority symPriority = calculateSymbianPriority(priority); |