summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread
diff options
context:
space:
mode:
authormread <qt-info@nokia.com>2012-01-04 15:19:49 +0000
committermread <qt-info@nokia.com>2012-01-04 15:40:15 +0000
commit2997b89e6480abfed356fbd6fe248bc6d2accbe2 (patch)
tree8335038e9e26480a44902a6a55565e459ee4ce74 /src/corelib/thread
parentdfe97e359443671f0cea9cddbe2ba0eccbaf48ce (diff)
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.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/corelib/thread/qthread_symbian.cpp b/src/corelib/thread/qthread_symbian.cpp
index 2ea1b447b8..78bb293c75 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);