summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qrefcount.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/tools/qrefcount.h')
-rw-r--r--src/corelib/tools/qrefcount.h18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/corelib/tools/qrefcount.h b/src/corelib/tools/qrefcount.h
index 84314b1fcc..3a8f0f3982 100644
--- a/src/corelib/tools/qrefcount.h
+++ b/src/corelib/tools/qrefcount.h
@@ -55,8 +55,10 @@ class RefCount
public:
inline bool ref() Q_DECL_NOTHROW {
int count = atomic.load();
+#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
if (count == 0) // !isSharable
return false;
+#endif
if (count != -1) // !isStatic
atomic.ref();
return true;
@@ -64,13 +66,16 @@ public:
inline bool deref() Q_DECL_NOTHROW {
int count = atomic.load();
+#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
if (count == 0) // !isSharable
return false;
+#endif
if (count == -1) // isStatic
return true;
return atomic.deref();
}
+#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
bool setSharable(bool sharable) Q_DECL_NOTHROW
{
Q_ASSERT(!isShared());
@@ -80,17 +85,18 @@ public:
return atomic.testAndSetRelaxed(1, 0);
}
- bool isStatic() const Q_DECL_NOTHROW
- {
- // Persistent object, never deleted
- return atomic.load() == -1;
- }
-
bool isSharable() const Q_DECL_NOTHROW
{
// Sharable === Shared ownership.
return atomic.load() != 0;
}
+#endif
+
+ bool isStatic() const Q_DECL_NOTHROW
+ {
+ // Persistent object, never deleted
+ return atomic.load() == -1;
+ }
bool isShared() const Q_DECL_NOTHROW
{