summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qobject.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2019-06-26 17:41:59 +0200
committerMarc Mutz <marc.mutz@kdab.com>2019-06-29 14:09:38 +0000
commit56962604254a31d5d54ea41044a5c251ff27fa0c (patch)
treebf88ba7c8436d80732c2454035545c0e0d516487 /src/corelib/kernel/qobject.cpp
parent66223727c708e48009cbf297721aa2d0134b48d2 (diff)
QObject: fix allocation of IDs for the undocumented userData() feature
This appears to have come to some fame on the internet, so better fix the implementation before we remove it in Qt 6. Change-Id: Ia37ca89105b13bea1ffcdce8b2e8cd957b7bd108 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel/qobject.cpp')
-rw-r--r--src/corelib/kernel/qobject.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 9a2ae36177..69556ba9e3 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -4187,13 +4187,14 @@ void QObject::dumpObjectInfo() const
}
#ifndef QT_NO_USERDATA
+static QBasicAtomicInteger<uint> user_data_registration = Q_BASIC_ATOMIC_INITIALIZER(0);
+
/*!
\internal
*/
uint QObject::registerUserData()
{
- static int user_data_registration = 0;
- return user_data_registration++;
+ return user_data_registration.fetchAndAddRelaxed(1);
}
/*!