summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/thread/qthread_unix.cpp10
-rw-r--r--src/corelib/thread/qthread_win.cpp7
2 files changed, 14 insertions, 3 deletions
diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp
index 8d2c83d519..205ae50035 100644
--- a/src/corelib/thread/qthread_unix.cpp
+++ b/src/corelib/thread/qthread_unix.cpp
@@ -315,10 +315,16 @@ void *QThreadPrivate::start(void *arg)
// Sets the name of the current thread. We can only do this
// when the thread is starting, as we don't have a cross
// platform way of setting the name of an arbitrary thread.
- if (Q_LIKELY(thr->objectName().isEmpty()))
+
+ // avoid interacting with the binding system while thread is
+ // not properly running yet
+ auto priv = QObjectPrivate::get(thr);
+ QString objectName = priv->extraData ? priv->extraData->objectName.valueBypassingBindings()
+ : QString();
+ if (Q_LIKELY(objectName.isEmpty()))
setCurrentThreadName(thr->metaObject()->className());
else
- setCurrentThreadName(thr->objectName().toLocal8Bit());
+ setCurrentThreadName(objectName.toLocal8Bit());
}
#endif
diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp
index 820ffa1149..8aa3f4c58b 100644
--- a/src/corelib/thread/qthread_win.cpp
+++ b/src/corelib/thread/qthread_win.cpp
@@ -316,7 +316,12 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
#if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC)
// sets the name of the current thread.
- QByteArray objectName = thr->objectName().toLocal8Bit();
+
+ // avoid interacting with the binding system while thread is
+ // not properly running yet
+ auto priv = QObjectPrivate::get(thr);
+ QByteArray objectName = (priv->extraData ? priv->extraData->objectName.valueBypassingBindings()
+ : QString()).toLocal8Bit();
qt_set_thread_name(HANDLE(-1),
objectName.isEmpty() ?
thr->metaObject()->className() : objectName.constData());