From 8abbbb4c482c32cd5342f5f8576cee8cbacc3737 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 15 Jul 2019 15:28:47 -0700 Subject: 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 --- src/corelib/tools/qvector.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 988d5a9e1b..57cf6e51ce 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -416,7 +416,7 @@ template void QVector::resize(int asize) { if (asize == d->size) - return; + return detach(); if (asize > int(d->alloc) || !isDetached()) { // there is not enough space QArrayData::AllocationOptions opt = asize > int(d->alloc) ? QArrayData::Grow : QArrayData::Default; realloc(qMax(int(d->alloc), asize), opt); -- cgit v1.2.3