QPixmapCache: Move qHash(Key) from _p.h to public header

... and make it a hidden friend.

This avoids ODR violations when, because they can't use ours (private,
and not exported), users try to produce their own version of
qHash(Key).

[ChangeLog][QtGui][QPixmapCache] Made the qHash() overload for
QPixmapCache::Key public (was: private) API.

Change-Id: I324ed001c0ae0a251ac2e1d04713013452ffff9c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 7fa3267fda6cff720cca44e829f9a39789031a54)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2023-04-04 11:40:36 +02:00 committed by Qt Cherry-pick Bot
parent 2df17d56b9
commit 211ff8ac53
3 changed files with 12 additions and 5 deletions

View File

@ -218,10 +218,15 @@ QT_BEGIN_INCLUDE_NAMESPACE
#include "qpixmapcache.moc"
QT_END_INCLUDE_NAMESPACE
size_t qHash(const QPixmapCache::Key &k, size_t seed)
/*!
size_t QPixmapCache::qHash(const Key &key, size_t seed = 0);
\since 6.6
Returns the hash value for the \a key, using \a seed to seed the calculation.
*/
size_t QPixmapCache::Key::hash(size_t seed) const noexcept
{
const auto *keyData = QPMCache::get(k);
return qHash(keyData ? keyData->key : 0, seed);
return qHash(this->d ? this->d->key : 0, seed);
}
QPMCache::QPMCache()

View File

@ -31,6 +31,10 @@ public:
bool isValid() const noexcept;
private:
friend size_t qHash(const QPixmapCache::Key &k, size_t seed = 0) noexcept
{ return k.hash(seed); }
size_t hash(size_t seed) const noexcept;
KeyData *d;
friend class QPMCache;
friend class QPixmapCache;

View File

@ -23,8 +23,6 @@
QT_BEGIN_NAMESPACE
size_t qHash(const QPixmapCache::Key &k, size_t seed = 0);
class QPixmapCache::KeyData
{
public: