summaryrefslogtreecommitdiffstats
path: root/src/network/kernel/qhostinfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/kernel/qhostinfo.cpp')
-rw-r--r--src/network/kernel/qhostinfo.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp
index 193c990d8c..d3a1858f86 100644
--- a/src/network/kernel/qhostinfo.cpp
+++ b/src/network/kernel/qhostinfo.cpp
@@ -183,7 +183,11 @@ void emit_results_ready(const QHostInfo &hostInfo, const QObject *receiver,
\sa QAbstractSocket, {http://www.rfc-editor.org/rfc/rfc3492.txt}{RFC 3492}
*/
-static QBasicAtomicInt theIdCounter = Q_BASIC_ATOMIC_INITIALIZER(1);
+static int nextId()
+{
+ static QBasicAtomicInt counter;
+ return 1 + counter.fetchAndAddRelaxed(1);
+}
/*!
Looks up the IP address(es) associated with host name \a name, and
@@ -229,7 +233,7 @@ int QHostInfo::lookupHost(const QString &name, QObject *receiver,
qRegisterMetaType<QHostInfo>();
- int id = theIdCounter.fetchAndAddRelaxed(1); // generate unique ID
+ int id = nextId(); // generate unique ID
if (name.isEmpty()) {
if (!receiver)
@@ -596,7 +600,7 @@ int QHostInfo::lookupHostImpl(const QString &name,
qRegisterMetaType<QHostInfo>();
- int id = theIdCounter.fetchAndAddRelaxed(1); // generate unique ID
+ int id = nextId(); // generate unique ID
if (Q_UNLIKELY(name.isEmpty())) {
QHostInfo hostInfo(id);