summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2023-07-06 21:41:51 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-07-09 21:57:51 +0000
commit734638bcf7d256ee1d4b384fdbd584c6aff37bc9 (patch)
tree9be747988feeae1d2f1d1ea20011f50fe0cc454f /src
parent44aa34149a1cee03e4b71116abeaabb7c1564dcd (diff)
QBluetoothAddress: add qHash() as a proper hidden friend
... removing the ODR-endangered private overload. While the QBluetoothAddress constructors are constexpr, the dtor is not, so qHash() can only be constexpr come Qt 7. Pre-program accordingly. Even though GCC and Clang accept the constexpr as long as we pass by reference-to-const, the actual constexpr'ness of the function cannot be used. Partially reverts d44a46e2bcc9ff119128759262c0422aa91bcd69. [ChangeLog][QtBluetooth][QBluetoothAddress] Added qHash(). Change-Id: I6f98eb867b4691eee2629fa63107f6b954787243 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 4d5da3f5beb7bc8588057e9f5304504fb3d220e5) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/bluetooth/bluez/bluetoothmanagement.cpp1
-rw-r--r--src/bluetooth/bluez/bluez5_helper_p.h5
-rw-r--r--src/bluetooth/qbluetoothaddress.cpp8
-rw-r--r--src/bluetooth/qbluetoothaddress.h3
4 files changed, 11 insertions, 6 deletions
diff --git a/src/bluetooth/bluez/bluetoothmanagement.cpp b/src/bluetooth/bluez/bluetoothmanagement.cpp
index 91cd44fe..15ca8e56 100644
--- a/src/bluetooth/bluez/bluetoothmanagement.cpp
+++ b/src/bluetooth/bluez/bluetoothmanagement.cpp
@@ -7,7 +7,6 @@
#include "bluetoothmanagement_p.h"
#include "bluez_data_p.h"
-#include "bluez5_helper_p.h"
#include "../qbluetoothsocketbase_p.h"
#include <unistd.h>
diff --git a/src/bluetooth/bluez/bluez5_helper_p.h b/src/bluetooth/bluez/bluez5_helper_p.h
index 3b751a93..7601c9c5 100644
--- a/src/bluetooth/bluez/bluez5_helper_p.h
+++ b/src/bluetooth/bluez/bluez5_helper_p.h
@@ -76,11 +76,6 @@ private:
QtBluezDiscoveryManagerPrivate *d;
};
-inline uint qHash(const QBluetoothAddress &address)
-{
- return qHash(address.toUInt64());
-}
-
QT_END_NAMESPACE
#endif
diff --git a/src/bluetooth/qbluetoothaddress.cpp b/src/bluetooth/qbluetoothaddress.cpp
index 2757879e..af85afa7 100644
--- a/src/bluetooth/qbluetoothaddress.cpp
+++ b/src/bluetooth/qbluetoothaddress.cpp
@@ -88,6 +88,14 @@ QBluetoothAddress &QBluetoothAddress::operator=(const QBluetoothAddress &other)
}
/*!
+ \fn QBluetoothAddress::qHash(QBluetoothAddress key, size_t seed)
+ \since 6.6
+
+ Returns the hash value for the \a key, using \a seed to seed the
+ calculation.
+*/
+
+/*!
Sets the Bluetooth address to 00:00:00:00:00:00.
*/
void QBluetoothAddress::clear()
diff --git a/src/bluetooth/qbluetoothaddress.h b/src/bluetooth/qbluetoothaddress.h
index 806f27ab..5a9f5793 100644
--- a/src/bluetooth/qbluetoothaddress.h
+++ b/src/bluetooth/qbluetoothaddress.h
@@ -7,6 +7,7 @@
#include <QtBluetooth/qtbluetoothglobal.h>
#include <QtCore/QByteArray>
+#include <QtCore/qhashfunctions.h>
#include <QtCore/QString>
#include <QtCore/QMetaType>
#include <QtCore/QDebug>
@@ -46,6 +47,8 @@ public:
private:
quint64 m_address = { 0 };
+ friend QT7_ONLY(constexpr) size_t qHash(const QBluetoothAddress &key, size_t seed = 0) noexcept
+ { return qHash(key.m_address, seed); }
#ifndef QT_NO_DEBUG_STREAM
friend QDebug operator<<(QDebug d, const QBluetoothAddress &a)
{