summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qthreadpool.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/thread/qthreadpool.cpp')
-rw-r--r--src/corelib/thread/qthreadpool.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/corelib/thread/qthreadpool.cpp b/src/corelib/thread/qthreadpool.cpp
index 9657112abc..1478cfcb19 100644
--- a/src/corelib/thread/qthreadpool.cpp
+++ b/src/corelib/thread/qthreadpool.cpp
@@ -40,13 +40,12 @@
#include "qthreadpool.h"
#include "qthreadpool_p.h"
#include "qdeadlinetimer.h"
+#include "qcoreapplication.h"
#include <algorithm>
QT_BEGIN_NAMESPACE
-Q_GLOBAL_STATIC(QThreadPool, theInstance)
-
/*
QThread wrapper, provides synchronization against a ThreadPool
*/
@@ -478,7 +477,13 @@ QThreadPool::~QThreadPool()
*/
QThreadPool *QThreadPool::globalInstance()
{
- return theInstance();
+ static QPointer<QThreadPool> theInstance;
+ static QBasicMutex theMutex;
+
+ const QMutexLocker locker(&theMutex);
+ if (theInstance.isNull() && !QCoreApplication::closingDown())
+ theInstance = new QThreadPool();
+ return theInstance;
}
/*!