summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qvector.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/tools/qvector.h')
-rw-r--r--src/corelib/tools/qvector.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index 22031645dc..0a32c96958 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -107,6 +107,7 @@ public:
inline void detach();
inline bool isDetached() const { return !d->ref.isShared(); }
+#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
inline void setSharable(bool sharable)
{
if (sharable == d->ref.isSharable())
@@ -122,6 +123,7 @@ public:
}
Q_ASSERT(d->ref.isSharable() == sharable);
}
+#endif
inline bool isSharedWith(const QVector<T> &other) const { return d == other.d; }
@@ -348,10 +350,12 @@ template <typename T>
void QVector<T>::detach()
{
if (!isDetached()) {
- if (d->alloc)
- reallocData(d->size, int(d->alloc));
- else
+#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+ if (!d->alloc)
d = Data::unsharableEmpty();
+ else
+#endif
+ reallocData(d->size, int(d->alloc));
}
Q_ASSERT(isDetached());
}
@@ -503,7 +507,9 @@ void QVector<T>::reallocData(const int asize, const int aalloc, QArrayData::Allo
x = Data::allocate(aalloc, options);
Q_CHECK_PTR(x);
// aalloc is bigger then 0 so it is not [un]sharedEmpty
+#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
Q_ASSERT(x->ref.isSharable() || options.testFlag(QArrayData::Unsharable));
+#endif
Q_ASSERT(!x->ref.isStatic());
x->size = asize;
@@ -569,7 +575,9 @@ void QVector<T>::reallocData(const int asize, const int aalloc, QArrayData::Allo
Q_ASSERT(d->data());
Q_ASSERT(uint(d->size) <= d->alloc);
+#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
Q_ASSERT(d != Data::unsharableEmpty());
+#endif
Q_ASSERT(aalloc ? d != Data::sharedNull() : d == Data::sharedNull());
Q_ASSERT(d->alloc >= uint(aalloc));
Q_ASSERT(d->size == asize);