summaryrefslogtreecommitdiffstats
path: root/src/network/kernel/qhostinfo_unix.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/kernel/qhostinfo_unix.cpp')
-rw-r--r--src/network/kernel/qhostinfo_unix.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/network/kernel/qhostinfo_unix.cpp b/src/network/kernel/qhostinfo_unix.cpp
index 625fbabf31..9b0a2ee669 100644
--- a/src/network/kernel/qhostinfo_unix.cpp
+++ b/src/network/kernel/qhostinfo_unix.cpp
@@ -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)
{