QMultiHash: fix operator==

An empty QMultiHash can still have an allocated dpointer, so we
can't desume that two hashes are different because one has a
dpointer and the other doesn't. Compares the sizes first, and
infer that equal size, and non-zero size, mean both have a dpointer.

Fixes: QTBUG-87575
Change-Id: I2e206bd071c02fb8970a4e77f8b0d29ad7e58bbe
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Giuseppe D'Angelo 2020-10-15 02:32:00 +02:00
parent 9f1e1eb552
commit ef1905aebc

View File

@ -1229,9 +1229,14 @@ public:
{
if (d == other.d)
return true;
if (!d || ! other.d)
if (m_size != other.m_size)
return false;
if (m_size != other.m_size || d->size != other.d->size)
if (m_size == 0)
return true;
// equal size, and both non-zero size => d pointers allocated for both
Q_ASSERT(d);
Q_ASSERT(other.d);
if (d->size != other.d->size)
return false;
for (auto it = other.d->begin(); it != other.d->end(); ++it) {
auto i = d->find(it.node()->key);