summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/thread/qthread_symbian.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/corelib/thread/qthread_symbian.cpp b/src/corelib/thread/qthread_symbian.cpp
index fd551ff..0cddb68 100644
--- a/src/corelib/thread/qthread_symbian.cpp
+++ b/src/corelib/thread/qthread_symbian.cpp
@@ -53,6 +53,11 @@
#include <hal_data.h>
#include <e32math.h>
+// This can be manually enabled if debugging thread problems
+#ifdef QT_USE_RTTI_IN_THREAD_CLASSNAME
+#include <typeinfo>
+#endif
+
// 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.
@@ -520,17 +525,23 @@ void QThread::start(Priority priority)
d->stackSize = 0x14000; // Maximum stack size on Symbian.
int code = KErrAlreadyExists;
- QString objName = objectName();
- TPtrC objNamePtr(qt_QString2TPtrC(objName));
+ QString className(QLatin1String(metaObject()->className()));
+#ifdef QT_USE_RTTI_IN_THREAD_CLASSNAME
+ // use RTTI, if enabled, to get a more accurate className. This must be manually enabled.
+ const char* rttiName = typeid(*this).name();
+ if (rttiName)
+ className = QLatin1String(rttiName);
+#endif
+ QString threadNameBase = QString(QLatin1String("%1_%2_v=0x%3_")).arg(objectName()).arg(className).arg(*(uint*)this,8,16,QLatin1Char('0'));
+ TPtrC threadNameBasePtr(qt_QString2TPtrC(threadNameBase));
TName name;
- objNamePtr.Set(objNamePtr.Left(qMin(objNamePtr.Length(), name.MaxLength() - 16)));
+ threadNameBasePtr.Set(threadNameBasePtr.Left(qMin(threadNameBasePtr.Length(), name.MaxLength() - 8)));
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
+ // generate a thread name with a random component to avoid and resolve name collisions
// a named thread can be opened from another process
name.Zero();
- name.Append(objNamePtr);
- name.AppendNumFixedWidth(int(this), EHex, 8);
+ name.Append(threadNameBasePtr);
name.AppendNumFixedWidth(Math::Random(), EHex, 8);
code = d->data->symbian_thread_handle.Create(name, (TThreadFunction) QThreadPrivate::start, d->stackSize, NULL, this);
}