diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2019-07-15 15:28:47 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2019-07-16 18:09:51 -0700 |
commit | 8abbbb4c482c32cd5342f5f8576cee8cbacc3737 (patch) | |
tree | c041b16154dd878cf5c6f0d80324edf4715503a8 /tests/auto | |
parent | a837ec15fec100567730a7bedb06655ef891ac96 (diff) |
Fix regression causing QVector::fill w/ same size to not detach
Caused by commit 01301b0b340df736dd1b0a54b3026e00b49c5ea3, which made
vector.resize(vector.size()) not to detach, which was used by fill() and
assumed that detaching happened. The test does not test the resize()
behavior, only that fill() is not broken anymore.
[ChangeLog][QtCore][QVector] Fixed a regression that caused fill() not
to detach, corrupting shared copies.
Fixes: QTBUG-77058
Change-Id: I6aed4df6a12e43c3ac8efffd15b1b527a8007bf3
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/corelib/tools/qvector/tst_qvector.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp index a7faeb5ca5..383318979d 100644 --- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp +++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp @@ -250,6 +250,7 @@ private slots: void fillInt() const; void fillMovable() const; void fillCustom() const; + void fillDetaches() const; void first() const; void fromListInt() const; void fromListMovable() const; @@ -1272,6 +1273,16 @@ void tst_QVector::fillCustom() const QCOMPARE(instancesCount, Custom::counter.loadAcquire()); } +void tst_QVector::fillDetaches() const +{ + QVector<int> test = { 1, 2, 3 }; + QVector<int> copy = test; + copy.fill(42); + + QCOMPARE(test, QVector<int>({1, 2, 3})); + QCOMPARE(copy, QVector<int>({42, 42, 42})); +} + void tst_QVector::first() const { QVector<int> myvec; |