Fix living QLibrary member after shutdown of QCoreApplication
LibResolv uses a QLibrary which is a QObject that must be deleted if the QCoreApplication is being destroyed to release the underlying library. A Q_GLOBAL_STATIC won't release any memory and is not able to manually release it. Pick-to: 5.15 Task-number: QTBUG-84234 Change-Id: I97fe5faca309e9c1e85435f602ad7f8c3f633b48 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
f6d1be7c66
commit
5dc4004afc
|
|
@ -156,7 +156,25 @@ LibResolv::LibResolv()
|
|||
}
|
||||
}
|
||||
}
|
||||
Q_GLOBAL_STATIC(LibResolv, libResolv)
|
||||
|
||||
LibResolv* libResolv()
|
||||
{
|
||||
static LibResolv* theLibResolv = nullptr;
|
||||
static QBasicMutex theMutex;
|
||||
|
||||
const QMutexLocker locker(&theMutex);
|
||||
if (theLibResolv == nullptr) {
|
||||
theLibResolv = new LibResolv();
|
||||
Q_ASSERT(QCoreApplication::instance());
|
||||
QObject::connect(QCoreApplication::instance(), &QCoreApplication::destroyed, [] {
|
||||
const QMutexLocker locker(&theMutex);
|
||||
delete theLibResolv;
|
||||
theLibResolv = nullptr;
|
||||
});
|
||||
}
|
||||
|
||||
return theLibResolv;
|
||||
}
|
||||
|
||||
static void resolveLibrary(LibResolvFeature f)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue