summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread
diff options
context:
space:
mode:
authorJuha Kukkonen <ext-juha.kukkonen@nokia.com>2012-04-20 15:20:39 +0300
committerQt by Nokia <qt-info@nokia.com>2012-04-26 01:30:12 +0200
commit3a4acb35029efb1d1f5a0e8d24ddd5838f8f89b9 (patch)
tree43c1cb181df3075e29113f3ab3c3a1f40456666b /src/corelib/thread
parenta2dfb824021ea01c1c9c81461b9f275643793542 (diff)
Fix QThread start failure due to bad thread name on Symbian
RThread::Create() deems a thread name to be invalid, if it contains any of the characters: "*", "?", ":" or character is outside 0x20 - 0x7e range. This matches to the logic in User::ValidateName() that is used by RThread::Create() to validate thread name. In addition, maximum thread name length is 80 character on Symbian. It was possible that thread name contained e.g. colon that caused RThread::Create() to fail with KErrBadName (-28). Fix ensures that thread name contains only allowed characters. Task-number: ou1cimx1#996187 Change-Id: Ie6dd8c60bfed4e2f6cc48607ff0ff940d9cdae8a Reviewed-by: Murray Read <ext-murray.2.read@nokia.com> Reviewed-by: Pasi Pentikäinen <ext-pasi.a.pentikainen@nokia.com>
Diffstat (limited to 'src/corelib/thread')
-rw-r--r--src/corelib/thread/qthread_symbian.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/corelib/thread/qthread_symbian.cpp b/src/corelib/thread/qthread_symbian.cpp
index 0cddb680dd..149da9c3b8 100644
--- a/src/corelib/thread/qthread_symbian.cpp
+++ b/src/corelib/thread/qthread_symbian.cpp
@@ -53,6 +53,7 @@
#include <hal_data.h>
#include <e32math.h>
+#include <QRegExp>
// This can be manually enabled if debugging thread problems
#ifdef QT_USE_RTTI_IN_THREAD_CLASSNAME
#include <typeinfo>
@@ -533,8 +534,16 @@ void QThread::start(Priority priority)
className = QLatin1String(rttiName);
#endif
QString threadNameBase = QString(QLatin1String("%1_%2_v=0x%3_")).arg(objectName()).arg(className).arg(*(uint*)this,8,16,QLatin1Char('0'));
+ // Thread name can contain only characters allowed by User::ValidateName() otherwise RThread::Create fails.
+ // Not allowed characters are:
+ // - any character outside range 0x20 - 0x7e
+ // - or asterisk, question mark or colon
+ const QRegExp notAllowedChars(QLatin1String("[^\\x20-\\x7e]|\\*|\\?|\\:"));
+ threadNameBase.replace(notAllowedChars, QLatin1String("_"));
+
TPtrC threadNameBasePtr(qt_QString2TPtrC(threadNameBase));
- TName name;
+ // max thread name length is KMaxKernelName
+ TBuf<KMaxKernelName> name;
threadNameBasePtr.Set(threadNameBasePtr.Left(qMin(threadNameBasePtr.Length(), name.MaxLength() - 8)));
const int MaxRetries = 10;
for (int i=0; i<MaxRetries && code == KErrAlreadyExists; i++) {