From 2f747bb57cd958f9fc65f406474c429ca00941ac Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 3 Dec 2020 09:04:07 +0100 Subject: Fix hashing of QPersistentModelIndex The hash and equality operators used need to be consistent with each other. Unfortunately, QPMI::operator==() is not suitable to do this. So specialize qHashEquals() for QPMI. Fixes: QTBUG-88966 Change-Id: If5f19a722ae9fc4e78e93537e7ea15726f148768 Reviewed-by: Jarek Kobus Reviewed-by: Volker Hilsheimer (cherry picked from commit 83e95956ed58e88b11e2cc3cb61c5beacb7985db) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/itemmodels/qabstractitemmodel.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/corelib/itemmodels/qabstractitemmodel.h') diff --git a/src/corelib/itemmodels/qabstractitemmodel.h b/src/corelib/itemmodels/qabstractitemmodel.h index 5d4ac59966..8340ca0e73 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.h +++ b/src/corelib/itemmodels/qabstractitemmodel.h @@ -242,6 +242,8 @@ public: private: QPersistentModelIndexData *d; friend size_t qHash(const QPersistentModelIndex &, size_t seed) noexcept; + friend bool qHashEquals(const QPersistentModelIndex &a, const QPersistentModelIndex &b) noexcept + { return a.d == b.d; } #ifndef QT_NO_DEBUG_STREAM friend Q_CORE_EXPORT QDebug operator<<(QDebug, const QPersistentModelIndex &); #endif -- cgit v1.2.3