      allThreads.insert(thread.data());
      ++activeThreads;
  
-@@ -444,7 +435,7 @@
+@@ -444,7 +436,13 @@
  */
  QThreadPool *QThreadPool::globalInstance()
  {
 -    return theInstance();
-+    return qApp->globalThreadPool();
++    return gThreadPool.data();
++}
++
++void
++QThreadPool::setGlobalInstance(QThreadPool* instance)
++{
++    gThreadPool.reset(instance);
  }
  
  /*!
 --- src/corelib/concurrent/qthreadpool.h.orig	2015-05-07 16:14:48.000000000 +0200
-+++ src/corelib/concurrent/qthreadpool.h	2016-03-17 15:54:48.000000000 +0100
-@@ -46,6 +46,7 @@
++++ src/corelib/concurrent/qthreadpool.h	2016-03-18 11:01:55.000000000 +0100
+@@ -46,15 +46,43 @@
  
  #include <QtCore/qthread.h>
  #include <QtCore/qrunnable.h>

--- src/corelib/concurrent/qthreadpool.cpp.orig	2015-05-07 16:14:48.000000000 +0200
+++ src/corelib/concurrent/qthreadpool.cpp	2016-03-17 15:57:50.000000000 +0100
@@ -42,6 +42,7 @@
 #include "qthreadpool.h"
 #include "qthreadpool_p.h"
 #include "qelapsedtimer.h"
+#include "QtCore/qcoreapplication.h"
 
 #ifndef QT_NO_THREAD
 
@@ -56,23 +57,6 @@
     return priority < p.second;
 }
 

 
 #ifndef QT_NO_THREAD
 
+#define QT_CUSTOM_THREADPOOL
+
 QT_BEGIN_HEADER
 QT_BEGIN_NAMESPACE
 
 QT_MODULE(Core)
 
