summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qvector.h
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-04-27 21:36:32 +0200
committerLiang Qi <liang.qi@theqtcompany.com>2015-04-27 21:36:32 +0200
commit1c8451bdbbd6ca909dfc5b96a24be909810522fc (patch)
tree9cc69a4794e23f7224d75fc2323fc70e294a9454 /src/corelib/tools/qvector.h
parent7ebec0fa848de299d4cdee06ccc611ee46494fbf (diff)
parent0635b1a69dd666f5eed4b096895bd80b1a9420ff (diff)
Merge remote-tracking branch 'origin/5.5' into dev
Conflicts: src/tools/qdoc/tree.cpp tests/auto/gui/painting/qcolor/tst_qcolor.cpp Change-Id: Iaa78f601a63191fa643aabf853520f913f2f0fdc
Diffstat (limited to 'src/corelib/tools/qvector.h')
-rw-r--r--src/corelib/tools/qvector.h17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index 12baecd37c..2eb2dc4550 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -608,16 +608,23 @@ Q_OUTOFLINE_TEMPLATE T QVector<T>::value(int i, const T &defaultValue) const
template <typename T>
void QVector<T>::append(const T &t)
{
- const T copy(t);
const bool isTooSmall = uint(d->size + 1) > d->alloc;
if (!isDetached() || isTooSmall) {
+ const T copy(t);
QArrayData::AllocationOptions opt(isTooSmall ? QArrayData::Grow : QArrayData::Default);
reallocData(d->size, isTooSmall ? d->size + 1 : d->alloc, opt);
+
+ if (QTypeInfo<T>::isComplex)
+ new (d->end()) T(copy);
+ else
+ *d->end() = copy;
+
+ } else {
+ if (QTypeInfo<T>::isComplex)
+ new (d->end()) T(t);
+ else
+ *d->end() = t;
}
- if (QTypeInfo<T>::isComplex)
- new (d->end()) T(copy);
- else
- *d->end() = copy;
++d->size;
}