Fix QMultiHash::operator== crash
QMultiHash::operator== crashes when comparing two unequal objects. This patch fixes it. Pick-to: 6.2 Fixes: QTBUG-98265 Change-Id: Ibf9fef3372a2b4581843be5f25e65cc9a55ef64d Reviewed-by: Lars Knoll <lars.knoll@qt.io>bb10
parent
090c7e3262
commit
838edd9c48
|
|
@ -1323,12 +1323,12 @@ public:
|
|||
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);
|
||||
if (i == d->end())
|
||||
auto *n = d->findNode(it.node()->key);
|
||||
if (!n)
|
||||
return false;
|
||||
Chain *e = it.node()->value;
|
||||
while (e) {
|
||||
Chain *oe = i.node()->value;
|
||||
Chain *oe = n->value;
|
||||
while (oe) {
|
||||
if (oe->value == e->value)
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -95,6 +95,8 @@ private slots:
|
|||
void fineTuningInEmptyHash();
|
||||
|
||||
void reserveShared();
|
||||
|
||||
void QTBUG98265();
|
||||
};
|
||||
|
||||
struct IdentityTracker {
|
||||
|
|
@ -1742,6 +1744,7 @@ void tst_QHash::qmultihash_specific()
|
|||
map2.insert(48, 3);
|
||||
QCOMPARE(map1.count(), map2.count());
|
||||
QVERIFY(map1.remove(42,5));
|
||||
QVERIFY(map1 != map2);
|
||||
QVERIFY(map2.remove(42,5));
|
||||
QVERIFY(map1 == map2);
|
||||
|
||||
|
|
@ -2615,5 +2618,14 @@ void tst_QHash::reserveShared()
|
|||
QCOMPARE(hash.capacity(), oldCap);
|
||||
}
|
||||
|
||||
void tst_QHash::QTBUG98265()
|
||||
{
|
||||
QMultiHash<QUuid, QByteArray> a;
|
||||
QMultiHash<QUuid, QByteArray> b;
|
||||
a.insert(QUuid("3e0dfb4d-90eb-43a4-bd54-88f5b69832c1"), QByteArray());
|
||||
b.insert(QUuid("1b710ada-3dd7-432e-b7c8-e852e59f46a0"), QByteArray());
|
||||
|
||||
QVERIFY(a != b);
|
||||
}
|
||||
QTEST_APPLESS_MAIN(tst_QHash)
|
||||
#include "tst_qhash.moc"
|
||||
|
|
|
|||
Loading…
Reference in New Issue