summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/tools/qcontiguouscache.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/corelib/tools/qcontiguouscache.h b/src/corelib/tools/qcontiguouscache.h
index b360850..9a6b9e3 100644
--- a/src/corelib/tools/qcontiguouscache.h
+++ b/src/corelib/tools/qcontiguouscache.h
@@ -392,10 +392,12 @@ void QContiguousCache<T>::insert(int pos, const T &value)
Q_ASSERT_X(pos >= 0 && pos < INT_MAX, "QContiguousCache<T>::insert", "index out of range");
detach();
if (containsIndex(pos)) {
- if(QTypeInfo<T>::isComplex)
+ if (QTypeInfo<T>::isComplex) {
+ (p->array + pos % d->alloc)->~T();
new (p->array + pos % d->alloc) T(value);
- else
+ } else {
p->array[pos % d->alloc] = value;
+ }
} else if (pos == d->offset-1)
prepend(value);
else if (pos == d->offset+d->count)