Fix living QObject after shutdown of QCoreApplication
QThreadPool is a QObject and must be deleted if the QCoreApplication is being destroyed to release the underlying ThreadData. A Q_GLOBAL_STATIC won't release any memory is not able to manually release it. Pick-to: 5.15 Task-number: QTBUG-84234 Change-Id: Ia82bcff2b564b753ed687f025ff86fa1bed1e64c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
727fab7d29
commit
1304040e5d
@ -892,8 +892,10 @@ QCoreApplication::~QCoreApplication()
|
|||||||
} QT_CATCH (...) {
|
} QT_CATCH (...) {
|
||||||
// swallow the exception, since destructors shouldn't throw
|
// swallow the exception, since destructors shouldn't throw
|
||||||
}
|
}
|
||||||
if (globalThreadPool)
|
if (globalThreadPool) {
|
||||||
globalThreadPool->waitForDone();
|
globalThreadPool->waitForDone();
|
||||||
|
delete globalThreadPool;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef QT_NO_QOBJECT
|
#ifndef QT_NO_QOBJECT
|
||||||
|
@ -40,13 +40,12 @@
|
|||||||
#include "qthreadpool.h"
|
#include "qthreadpool.h"
|
||||||
#include "qthreadpool_p.h"
|
#include "qthreadpool_p.h"
|
||||||
#include "qdeadlinetimer.h"
|
#include "qdeadlinetimer.h"
|
||||||
|
#include "qcoreapplication.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
Q_GLOBAL_STATIC(QThreadPool, theInstance)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
QThread wrapper, provides synchronization against a ThreadPool
|
QThread wrapper, provides synchronization against a ThreadPool
|
||||||
*/
|
*/
|
||||||
@ -478,7 +477,13 @@ QThreadPool::~QThreadPool()
|
|||||||
*/
|
*/
|
||||||
QThreadPool *QThreadPool::globalInstance()
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
Loading…
x
Reference in New Issue
Block a user