diff options
Diffstat (limited to 'src/network/kernel/qhostinfo.cpp')
-rw-r--r-- | src/network/kernel/qhostinfo.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index 115f3445b9..db414a52f2 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<OutputIt1, OutputIt2> 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; +} + } /* |