summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2015-04-03 19:19:54 -0700
committerMarc Mutz <marc.mutz@kdab.com>2015-07-16 13:20:59 +0000
commit827f934760953466549952162388b1f0ba1955a5 (patch)
tree332536c05724e2362a70ffd0c9f1e8e39207959e /src/corelib/thread
parent73991bee3802e4de8dbe5cc64a881cd93f21a95c (diff)
QThread: simplify the pthread_cleanup_pop function
Make sure that the QString is not in scope anymore when the pthread cleanup happens. C++ destructors in scope are pthread cleanup handlers. Change-Id: I9a75ad8521ae4e5cbbe5ffff13d1ae1c7e31f6bb Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/corelib/thread')
-rw-r--r--src/corelib/thread/qthread_unix.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp
index 77093c9cf1..f054a727cf 100644
--- a/src/corelib/thread/qthread_unix.cpp
+++ b/src/corelib/thread/qthread_unix.cpp
@@ -313,14 +313,15 @@ void *QThreadPrivate::start(void *arg)
createEventDispatcher(data);
#if (defined(Q_OS_LINUX) || defined(Q_OS_MAC) || defined(Q_OS_QNX))
- // sets the name of the current thread.
- QString objectName = thr->objectName();
-
- if (Q_LIKELY(objectName.isEmpty()))
- setCurrentThreadName(thr->d_func()->thread_id, thr->metaObject()->className());
- else
- setCurrentThreadName(thr->d_func()->thread_id, objectName.toLocal8Bit());
+ {
+ // sets the name of the current thread.
+ QString objectName = thr->objectName();
+ if (Q_LIKELY(objectName.isEmpty()))
+ setCurrentThreadName(thr->d_func()->thread_id, thr->metaObject()->className());
+ else
+ setCurrentThreadName(thr->d_func()->thread_id, objectName.toLocal8Bit());
+ }
#endif
emit thr->started(QThread::QPrivateSignal());