From 5bfeab8749ce6820d55135b81665a7231d3b1504 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 5 Jul 2011 23:46:19 +0200 Subject: Make all uses of QBasicAtomicInt and Pointer use load() and store() Most of these changes are search-and-replace of d->ref ==, d->ref != and d->ref =. The QBasicAtomicPointer in QObjectPrivate::Connection didn't need to be basic, so I made it QAtomicPointer. Change-Id: Ie3271abd1728af599f9ab17c6f4868e475f17bb6 Reviewed-on: http://codereview.qt-project.org/5030 Reviewed-by: Qt Sanity Bot Reviewed-by: Bradley T. Hughes Reviewed-by: Lars Knoll --- src/corelib/global/qglobal.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/corelib/global/qglobal.h') diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 2d2db2440d..228c9a3469 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1909,8 +1909,8 @@ public: inline ~QGlobalStaticDeleter() { - delete globalStatic.pointer; - globalStatic.pointer = 0; + delete globalStatic.pointer.load(); + globalStatic.pointer.store(0); globalStatic.destroyed = true; } }; @@ -1920,14 +1920,14 @@ public: { \ static QGlobalStatic thisGlobalStatic \ = { Q_BASIC_ATOMIC_INITIALIZER(0), false }; \ - if (!thisGlobalStatic.pointer && !thisGlobalStatic.destroyed) { \ + if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { \ TYPE *x = new TYPE; \ if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) \ delete x; \ else \ static QGlobalStaticDeleter cleanup(thisGlobalStatic); \ } \ - return thisGlobalStatic.pointer; \ + return thisGlobalStatic.pointer.load(); \ } #define Q_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS) \ @@ -1935,14 +1935,14 @@ public: { \ static QGlobalStatic thisGlobalStatic \ = { Q_BASIC_ATOMIC_INITIALIZER(0), false }; \ - if (!thisGlobalStatic.pointer && !thisGlobalStatic.destroyed) { \ + if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { \ TYPE *x = new TYPE ARGS; \ if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) \ delete x; \ else \ static QGlobalStaticDeleter cleanup(thisGlobalStatic); \ } \ - return thisGlobalStatic.pointer; \ + return thisGlobalStatic.pointer.load(); \ } #define Q_GLOBAL_STATIC_WITH_INITIALIZER(TYPE, NAME, INITIALIZER) \ @@ -1950,7 +1950,7 @@ public: { \ static QGlobalStatic thisGlobalStatic \ = { Q_BASIC_ATOMIC_INITIALIZER(0), false }; \ - if (!thisGlobalStatic.pointer && !thisGlobalStatic.destroyed) { \ + if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { \ QScopedPointer x(new TYPE); \ INITIALIZER; \ if (thisGlobalStatic.pointer.testAndSetOrdered(0, x.data())) { \ @@ -1958,7 +1958,7 @@ public: x.take(); \ } \ } \ - return thisGlobalStatic.pointer; \ + return thisGlobalStatic.pointer.load(); \ } #endif -- cgit v1.2.3