From 827f934760953466549952162388b1f0ba1955a5 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 3 Apr 2015 19:19:54 -0700 Subject: [PATCH] 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) Reviewed-by: Marc Mutz --- src/corelib/thread/qthread_unix.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index 77093c9cf1f..f054a727cfa 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());