summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qlist.h7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index a704de54ea..ebb0fd9531 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -528,8 +528,7 @@ inline void QList<T>::remove(qsizetype i, qsizetype n)
((d->flags() & Data::CapacityReserved) == 0
&& newSize < d->allocatedCapacity()/2)) {
// allocate memory
- DataPointer detached(Data::allocate(d->detachCapacity(newSize),
- d->detachFlags() & ~(Data::GrowsBackwards | Data::GrowsForward)));
+ DataPointer detached(Data::allocate(d->detachCapacity(newSize), d->detachFlags()));
const_iterator where = constBegin() + i;
if (newSize) {
detached->copyAppend(constBegin(), where);
@@ -616,7 +615,7 @@ QList<T>::insert(qsizetype i, qsizetype n, parameter_type t)
const bool shouldGrow = d->shouldGrowBeforeInsert(d.begin() + i, n);
if (d->needsDetach() || newSize > d->allocatedCapacity() || shouldGrow) {
typename Data::ArrayOptions flags = d->detachFlags() | Data::GrowsForward;
- if (i <= d.size / 4)
+ if (d.size != 0 && i <= d.size / 4)
flags |= Data::GrowsBackwards;
DataPointer detached(DataPointer::allocateGrow(d, newSize, flags));
@@ -648,7 +647,7 @@ QList<T>::emplace(qsizetype i, Args&&... args)
const size_t newSize = size() + 1;
if (d->needsDetach() || newSize > d->allocatedCapacity() || shouldGrow) {
typename Data::ArrayOptions flags = d->detachFlags() | Data::GrowsForward;
- if (i <= d.size / 4)
+ if (d.size != 0 && i <= d.size / 4)
flags |= Data::GrowsBackwards;
DataPointer detached(DataPointer::allocateGrow(d, newSize, flags));