summaryrefslogtreecommitdiffstats
path: root/src/corelib/global
diff options
context:
space:
mode:
authorCasper van Donderen <casper.vandonderen@nokia.com>2011-08-30 08:40:03 (GMT)
committerCasper van Donderen <casper.vandonderen@nokia.com>2011-08-30 08:40:03 (GMT)
commit7f27ebb0383414f15f391151655e5b09952f8ccd (patch)
tree8af7b866af6115924a13896013f5b6f5da686de6 /src/corelib/global
parent3dccb66b3b81627fb70c7eeccdf32b96d8add8b7 (diff)
parent78c5825cfb7702350636b7624bf79311dbd0dbd5 (diff)
downloadQt-7f27ebb0383414f15f391151655e5b09952f8ccd.zip
Qt-7f27ebb0383414f15f391151655e5b09952f8ccd.tar.gz
Qt-7f27ebb0383414f15f391151655e5b09952f8ccd.tar.bz2
Merge remote branch 'mainline/4.8'
Diffstat (limited to 'src/corelib/global')
-rw-r--r--src/corelib/global/qglobal.h37
1 files changed, 19 insertions, 18 deletions
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 9c7f1c6..cfe5eea 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -1924,50 +1924,51 @@ public:
}
};
+#define Q_GLOBAL_STATIC_INIT(TYPE, NAME) \
+ static QGlobalStatic<TYPE > this_ ## NAME \
+ = { Q_BASIC_ATOMIC_INITIALIZER(0), false }
+
#define Q_GLOBAL_STATIC(TYPE, NAME) \
static TYPE *NAME() \
{ \
- static QGlobalStatic<TYPE > thisGlobalStatic \
- = { Q_BASIC_ATOMIC_INITIALIZER(0), false }; \
- if (!thisGlobalStatic.pointer && !thisGlobalStatic.destroyed) { \
+ Q_GLOBAL_STATIC_INIT(TYPE, _StaticVar_); \
+ if (!this__StaticVar_.pointer && !this__StaticVar_.destroyed) { \
TYPE *x = new TYPE; \
- if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) \
+ if (!this__StaticVar_.pointer.testAndSetOrdered(0, x)) \
delete x; \
else \
- static QGlobalStaticDeleter<TYPE > cleanup(thisGlobalStatic); \
+ static QGlobalStaticDeleter<TYPE > cleanup(this__StaticVar_); \
} \
- return thisGlobalStatic.pointer; \
+ return this__StaticVar_.pointer; \
}
#define Q_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS) \
static TYPE *NAME() \
{ \
- static QGlobalStatic<TYPE > thisGlobalStatic \
- = { Q_BASIC_ATOMIC_INITIALIZER(0), false }; \
- if (!thisGlobalStatic.pointer && !thisGlobalStatic.destroyed) { \
+ Q_GLOBAL_STATIC_INIT(TYPE, _StaticVar_); \
+ if (!this__StaticVar_.pointer && !this__StaticVar_.destroyed) { \
TYPE *x = new TYPE ARGS; \
- if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) \
+ if (!this__StaticVar_.pointer.testAndSetOrdered(0, x)) \
delete x; \
else \
- static QGlobalStaticDeleter<TYPE > cleanup(thisGlobalStatic); \
+ static QGlobalStaticDeleter<TYPE > cleanup(this__StaticVar_); \
} \
- return thisGlobalStatic.pointer; \
+ return this__StaticVar_.pointer; \
}
#define Q_GLOBAL_STATIC_WITH_INITIALIZER(TYPE, NAME, INITIALIZER) \
static TYPE *NAME() \
{ \
- static QGlobalStatic<TYPE > thisGlobalStatic \
- = { Q_BASIC_ATOMIC_INITIALIZER(0), false }; \
- if (!thisGlobalStatic.pointer && !thisGlobalStatic.destroyed) { \
+ Q_GLOBAL_STATIC_INIT(TYPE, _StaticVar_); \
+ if (!this__StaticVar_.pointer && !this__StaticVar_.destroyed) { \
QScopedPointer<TYPE > x(new TYPE); \
INITIALIZER; \
- if (thisGlobalStatic.pointer.testAndSetOrdered(0, x.data())) { \
- static QGlobalStaticDeleter<TYPE > cleanup(thisGlobalStatic); \
+ if (this__StaticVar_.pointer.testAndSetOrdered(0, x.data())) { \
+ static QGlobalStaticDeleter<TYPE > cleanup(this__StaticVar_); \
x.take(); \
} \
} \
- return thisGlobalStatic.pointer; \
+ return this__StaticVar_.pointer; \
}
#endif