QList: don't detach twice in operator[]

We first detached in operator[] itself, then in the data()
call.

Change-Id: I18b8b282b3b879125db350e0127953f83f773619
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
This commit is contained in:
Mårten Nordheim 2022-08-26 22:24:04 +02:00
parent f039147165
commit 52162eebe5

View File

@ -426,7 +426,7 @@ public:
reference operator[](qsizetype i)
{
Q_ASSERT_X(size_t(i) < size_t(d->size), "QList::operator[]", "index out of range");
detach();
// don't detach() here, we detach in data below:
return data()[i];
}
const_reference operator[](qsizetype i) const noexcept { return at(i); }