Add qHash(QSslError) overload
qsslsocket_winrt.cpp defined it locally, which runs the risk of clashes with a potential user-defined qHash(QSslError), so make it public. Also included both .error() and .certificate() in the hash, as both of these are used to determine equality (the WinRT version only used .error()). [ChangeLog][QtNetwork][QSslError] Can now be used in QSet/QHash. Change-Id: Ieb7995bed491ff011d4be9dad544248b56fd4f73 Reviewed-by: Oliver Wolff <oliver.wolff@digia.com> Reviewed-by: Andrew Knight <andrew.knight@digia.com>
This commit is contained in:
parent
e8bdc949fc
commit
32dfbd6dbf
@ -305,6 +305,19 @@ QSslCertificate QSslError::certificate() const
|
||||
return d->certificate;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the hash value for the \a key, using \a seed to seed the calculation.
|
||||
\since 5.4
|
||||
\relates QHash
|
||||
*/
|
||||
uint qHash(const QSslError &key, uint seed) Q_DECL_NOTHROW
|
||||
{
|
||||
// 2x boost::hash_combine inlined:
|
||||
seed ^= qHash(key.error()) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
|
||||
seed ^= qHash(key.certificate()) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
|
||||
return seed;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
//class QDebug;
|
||||
QDebug operator<<(QDebug debug, const QSslError &error)
|
||||
|
@ -102,6 +102,8 @@ private:
|
||||
};
|
||||
Q_DECLARE_SHARED(QSslError)
|
||||
|
||||
Q_NETWORK_EXPORT uint qHash(const QSslError &key, uint seed = 0) Q_DECL_NOTHROW;
|
||||
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
class QDebug;
|
||||
Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, const QSslError &error);
|
||||
|
@ -65,11 +65,6 @@ using namespace ABI::Windows::Storage::Streams;
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
// For QSet<QSslError>
|
||||
inline uint qHash(const QSslError &error, uint seed)
|
||||
Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(error)))
|
||||
{ return (qHash(error.error()) ^ seed); }
|
||||
|
||||
bool QSslSocketPrivate::s_libraryLoaded = true;
|
||||
bool QSslSocketPrivate::s_loadRootCertsOnDemand = true;
|
||||
bool QSslSocketPrivate::s_loadedCiphersAndCerts = false;
|
||||
|
@ -64,6 +64,7 @@ public:
|
||||
#ifndef QT_NO_SSL
|
||||
private slots:
|
||||
void constructing();
|
||||
void hash();
|
||||
#endif
|
||||
|
||||
private:
|
||||
@ -79,6 +80,14 @@ void tst_QSslError::constructing()
|
||||
QSslError error;
|
||||
}
|
||||
|
||||
void tst_QSslError::hash()
|
||||
{
|
||||
// mostly a compile-only test, to check that qHash(QSslError) is found
|
||||
QSet<QSslError> errors;
|
||||
errors << QSslError();
|
||||
QCOMPARE(errors.size(), 1);
|
||||
}
|
||||
|
||||
#endif // QT_NO_SSL
|
||||
|
||||
QTEST_MAIN(tst_QSslError)
|
||||
|
Loading…
Reference in New Issue
Block a user