summaryrefslogtreecommitdiffstats
path: root/src/network/kernel/qhostinfo_unix.cpp
diff options
context:
space:
mode:
authorMike Achtelik <mike.achtelik@gmail.com>2021-10-18 13:35:15 +0200
committerMike Achtelik <mike.achtelik@gmail.com>2021-11-18 20:53:27 +0100
commitf7fd57075be0f504cad46e9a2e78caf3d54979af (patch)
treeed0c4739aff627488746d6fc973e4aee9da7ba33 /src/network/kernel/qhostinfo_unix.cpp
parent1a8b7eb1d4f27e74621ee94c01dbeda3afd302c7 (diff)
Introduce Q_APPLICATION_STATIC
QObjects must be deleted if the QCoreApplication is being destroyed. This was previously done by implementing custom code in qtbase and other modules. So unify it and introduce a Q_APPLICATION_STATIC, based on the Q_GLOBAL_STATIC, which centralises the logic. Since we still have a few remaining living QObjects, this comes in handy to fix those as well. Task-number: QTBUG-84234 Change-Id: I3040a2280ff56291f2b1c39948c06a23597865c4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/network/kernel/qhostinfo_unix.cpp')
-rw-r--r--src/network/kernel/qhostinfo_unix.cpp21
1 files changed, 3 insertions, 18 deletions
diff --git a/src/network/kernel/qhostinfo_unix.cpp b/src/network/kernel/qhostinfo_unix.cpp
index 9b0a2ee669..3ccf8b217b 100644
--- a/src/network/kernel/qhostinfo_unix.cpp
+++ b/src/network/kernel/qhostinfo_unix.cpp
@@ -53,6 +53,8 @@
#include <qfile.h>
#include <private/qnet_unix_p.h>
+#include "QtCore/qapplicationstatic.h"
+
#include <sys/types.h>
#include <netdb.h>
#include <arpa/inet.h>
@@ -157,24 +159,7 @@ 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;
-}
+Q_APPLICATION_STATIC(LibResolv, libResolv)
static void resolveLibrary(LibResolvFeature f)
{