diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-01-31 12:11:54 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-04-09 20:03:25 +0200 |
commit | c6cdf38e752c22babdbe645366bdfb7ce51d01ff (patch) | |
tree | 450b02523cb5a16791674ad1d06fb68c72eac971 /src/corelib/itemmodels | |
parent | 775945137b6ef62de9a7d416b1fe59d79006ba82 (diff) |
Change qHash() to work with size_t instead of uint
This is required, so that QHash and QSet can hold more
than 2^32 items on 64 bit platforms.
The actual hashing functions for strings are still 32bit, this will
be changed in a follow-up commit.
Change-Id: I4372125252486075ff3a0b45ecfa818359fe103b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/itemmodels')
-rw-r--r-- | src/corelib/itemmodels/qabstractitemmodel.cpp | 2 | ||||
-rw-r--r-- | src/corelib/itemmodels/qabstractitemmodel.h | 10 | ||||
-rw-r--r-- | src/corelib/itemmodels/qitemselectionmodel.h | 3 |
3 files changed, 6 insertions, 9 deletions
diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index 57a6c2f239..3bc3b546da 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -3978,7 +3978,7 @@ bool QAbstractListModel::dropMimeData(const QMimeData *data, Qt::DropAction acti */ /*! - \fn uint qHash(const QPersistentModelIndex &index, uint seed = 0) + \fn size_t qHash(const QPersistentModelIndex &index, size_t seed = 0) \since 5.0 \relates QPersistentModelIndex diff --git a/src/corelib/itemmodels/qabstractitemmodel.h b/src/corelib/itemmodels/qabstractitemmodel.h index 2cc1bd8ce6..86ff361ccb 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.h +++ b/src/corelib/itemmodels/qabstractitemmodel.h @@ -103,7 +103,7 @@ Q_CORE_EXPORT QDebug operator<<(QDebug, const QModelIndex &); class QPersistentModelIndexData; // qHash is a friend, but we can't use default arguments for friends (§8.3.6.4) -uint qHash(const QPersistentModelIndex &index, uint seed = 0) noexcept; +size_t qHash(const QPersistentModelIndex &index, size_t seed = 0) noexcept; class Q_CORE_EXPORT QPersistentModelIndex { @@ -141,14 +141,14 @@ public: bool isValid() const; private: QPersistentModelIndexData *d; - friend uint qHash(const QPersistentModelIndex &, uint seed) noexcept; + friend size_t qHash(const QPersistentModelIndex &, size_t seed) noexcept; #ifndef QT_NO_DEBUG_STREAM friend Q_CORE_EXPORT QDebug operator<<(QDebug, const QPersistentModelIndex &); #endif }; Q_DECLARE_SHARED(QPersistentModelIndex) -inline uint qHash(const QPersistentModelIndex &index, uint seed) noexcept +inline size_t qHash(const QPersistentModelIndex &index, size_t seed) noexcept { return qHash(index.d, seed); } @@ -461,8 +461,8 @@ inline QVariant QModelIndex::data(int arole) const inline Qt::ItemFlags QModelIndex::flags() const { return m ? m->flags(*this) : Qt::ItemFlags(); } -inline uint qHash(const QModelIndex &index) noexcept -{ return uint((uint(index.row()) << 4) + index.column() + index.internalId()); } +inline size_t qHash(const QModelIndex &index, size_t seed) noexcept +{ return size_t((size_t(index.row()) << 4) + size_t(index.column()) + index.internalId()) ^ seed; } QT_END_NAMESPACE diff --git a/src/corelib/itemmodels/qitemselectionmodel.h b/src/corelib/itemmodels/qitemselectionmodel.h index 5421eb2afa..a1badc7693 100644 --- a/src/corelib/itemmodels/qitemselectionmodel.h +++ b/src/corelib/itemmodels/qitemselectionmodel.h @@ -223,9 +223,6 @@ private: Q_DECLARE_OPERATORS_FOR_FLAGS(QItemSelectionModel::SelectionFlags) -// dummy implentation of qHash() necessary for instantiating QList<QItemSelectionRange>::toSet() with MSVC -inline uint qHash(const QItemSelectionRange &) { return 0; } - #ifdef Q_CC_MSVC /* |