diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index 115f3445b90..db414a52f24 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -71,8 +71,6 @@ QT_BEGIN_NAMESPACE //#define QHOSTINFO_DEBUG -Q_GLOBAL_STATIC(QHostInfoLookupManager, theHostInfoLookupManager) - namespace { struct ToBeLookedUpEquals { typedef bool result_type; @@ -101,6 +99,25 @@ std::pair separate_if(InputIt first, InputIt last, OutputI return std::make_pair(dest1, dest2); } +QHostInfoLookupManager* theHostInfoLookupManager() +{ + static QHostInfoLookupManager* theManager = nullptr; + static QBasicMutex theMutex; + + const QMutexLocker locker(&theMutex); + if (theManager == nullptr) { + theManager = new QHostInfoLookupManager(); + Q_ASSERT(QCoreApplication::instance()); + QObject::connect(QCoreApplication::instance(), &QCoreApplication::destroyed, [] { + const QMutexLocker locker(&theMutex); + delete theManager; + theManager = nullptr; + }); + } + + return theManager; +} + } /*