diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2021-04-02 13:48:37 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2021-04-03 16:15:29 -0700 |
commit | 451fb66212b015b44a017e05a224af2df9a95755 (patch) | |
tree | 58098bac1eb6cdb815524130a4dbf80b14304394 /src/corelib/thread | |
parent | 33786e7b02470ce45dcac54e5c374ee7622cb620 (diff) |
QThreadPool: let the started thread have the same name as the pool
If the pool has a name. This should make identifying threads belonging
to different pools easier in process-inspection tools.
Fixes: QTBUG-92004
Change-Id: Id2983978ad544ff79911fffd167225902efeb855
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Diffstat (limited to 'src/corelib/thread')
-rw-r--r-- | src/corelib/thread/qthreadpool.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/corelib/thread/qthreadpool.cpp b/src/corelib/thread/qthreadpool.cpp index 911bf8a53a..0c95912bc4 100644 --- a/src/corelib/thread/qthreadpool.cpp +++ b/src/corelib/thread/qthreadpool.cpp @@ -257,9 +257,15 @@ bool QThreadPoolPrivate::tooManyThreadsActive() const */ void QThreadPoolPrivate::startThread(QRunnable *runnable) { + Q_Q(QThreadPool); Q_ASSERT(runnable != nullptr); QScopedPointer<QThreadPoolThread> thread(new QThreadPoolThread(this)); - thread->setObjectName(QLatin1String("Thread (pooled)")); + QString objectName; + if (QString myName = q->objectName(); !myName.isEmpty()) + objectName = myName; + else + objectName = QLatin1String("Thread (pooled)"); + thread->setObjectName(objectName); Q_ASSERT(!allThreads.contains(thread.data())); // if this assert hits, we have an ABA problem (deleted threads don't get removed here) allThreads.insert(thread.data()); ++activeThreads; |