summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/corelib/tools/qlist.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index 662fede6f7..b50cd9090f 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -834,8 +834,11 @@ inline QList<T> &QList<T>::fill(parameter_type t, qsizetype newSize)
// we're detached
const T copy(t);
d->assign(d.begin(), d.begin() + qMin(size(), newSize), t);
- if (newSize > size())
+ if (newSize > size()) {
d->copyAppend(newSize - size(), copy);
+ } else if (newSize < size()) {
+ d->truncate(newSize);
+ }
}
return *this;
}