summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2023-08-11 15:50:38 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-08-18 13:00:48 +0000
commit246dfef3efc6fc931c73743f9569e89cb599f558 (patch)
tree8a6a0014ef0513a658145a522c8224dd12887f74
parent00ee6a6121844c6c81e974d459c9474cfe1ab4a8 (diff)
QBluetoothUuid: inherit all ctors from QUuid
QBluetoothUuid clearly is-a QUuid, so it should have the same constructors, though it may add its own on top. Three Qt releases (6.3-6.6) of QUuid changes have, however, not been properly reflected in QBluetoothUuid, so fix it once and for all by adding using QUuid::QUuid; to QBluetoothUuid, thereby inheriting all the QUuid ctors (except SMFs) that QBluethoothUuid doesn't supply itself. This fixes or simplifies: - The Id128Bytes ctor, which we don't need to supply at all now. - The QString ctor, which was replaced by a QAnyStringView overload in QUuid a long time ago (6.3). - Anything else that we have missed in the past (GUID, e.g.). The superfluous constructors still have to be retained in the ABI, because QBluetoothUuid is unfortunately exported wholesale. This affects only the QString ctor. The other one was not in 6.5, and we don't provide BC with pre-releases of Qt. Add some variance to the fromString() tests now that we have QAnyStringView instead of just QString. Found in API-review. [ChangeLog][QtBluetooth] QBluetoothUuid now provides all the constructors that QUuid also provides (incl. from GUID and QAnyStringView). Change-Id: I2cb76a9a9cbc47f2fd4e637bdb41233d1ffc6972 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> (cherry picked from commit aff0acdeee12acf6a85f479f160a0d4776f79d7c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/bluetooth/qbluetoothuuid.cpp13
-rw-r--r--src/bluetooth/qbluetoothuuid.h5
-rw-r--r--src/bluetooth/removed_api.cpp7
-rw-r--r--tests/auto/qbluetoothuuid/tst_qbluetoothuuid.cpp6
4 files changed, 13 insertions, 18 deletions
diff --git a/src/bluetooth/qbluetoothuuid.cpp b/src/bluetooth/qbluetoothuuid.cpp
index ef6db13c..4a0f007b 100644
--- a/src/bluetooth/qbluetoothuuid.cpp
+++ b/src/bluetooth/qbluetoothuuid.cpp
@@ -561,19 +561,6 @@ quint128 QBluetoothUuid::toUInt128(QSysInfo::Endian order) const noexcept
*/
/*!
- Creates a QBluetoothUuid object from the string \a uuid,
- which must be formatted as five hex fields separated by '-',
- e.g., "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}" where 'x' is a hex digit.
- The curly braces shown here are optional, but it is normal to include them.
- If the conversion fails, a null UUID is created. See \l QUuid::toString() for an
- explanation of how the five hex fields map to the public data members in QUuid.
-*/
-QBluetoothUuid::QBluetoothUuid(const QString &uuid)
-: QUuid(uuid)
-{
-}
-
-/*!
\fn QBluetoothUuid::QBluetoothUuid(const QUuid &uuid)
Constructs a new Bluetooth UUID that is a copy of \a uuid.
diff --git a/src/bluetooth/qbluetoothuuid.h b/src/bluetooth/qbluetoothuuid.h
index 07298da7..b0a7dcc2 100644
--- a/src/bluetooth/qbluetoothuuid.h
+++ b/src/bluetooth/qbluetoothuuid.h
@@ -352,15 +352,16 @@ public:
: QUuid(uuid, 0x0, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb) {};
// end of bluetooth-specific constructors; rest is essentially `using QUuid::QUuid;`
+ using QUuid::QUuid;
#if QT_BLUETOOTH_REMOVED_SINCE(6, 6)
explicit QBluetoothUuid(quint128 uuid);
#endif
QT6_ONLY(QT_POST_CXX17_API_IN_EXPORTED_CLASS) // quint128 changes based on QT_SUPPORTS_INT128!
explicit QBluetoothUuid(quint128 uuid, QSysInfo::Endian order = QSysInfo::BigEndian) noexcept
: QUuid{fromBytes(&uuid, order)} {}
- explicit QBluetoothUuid(Id128Bytes uuid, QSysInfo::Endian order = QSysInfo::BigEndian) noexcept
- : QUuid(uuid, order) {};
+#if QT_BLUETOOTH_REMOVED_SINCE(6, 6) // actually 6.3 (cf. QUuid)
explicit QBluetoothUuid(const QString &uuid);
+#endif
QBluetoothUuid(const QBluetoothUuid &uuid) = default;
QT_BLUETOOTH_INLINE_SINCE(6, 6)
QBluetoothUuid(QUuid QT6_ONLY(const &)uuid);
diff --git a/src/bluetooth/removed_api.cpp b/src/bluetooth/removed_api.cpp
index da42f242..c4f37b68 100644
--- a/src/bluetooth/removed_api.cpp
+++ b/src/bluetooth/removed_api.cpp
@@ -39,6 +39,13 @@ quint128 QBluetoothUuid::toUInt128() const
return uuid;
}
+// END quint128 functions
+
+QBluetoothUuid::QBluetoothUuid(const QString &uuid)
+ : QUuid(qToAnyStringViewIgnoringNull(uuid))
+{
+}
+
#ifndef QT_NO_DEBUG_STREAM
QDebug QBluetoothUuid::streamingOperator(QDebug debug, const QBluetoothUuid &uuid)
{
diff --git a/tests/auto/qbluetoothuuid/tst_qbluetoothuuid.cpp b/tests/auto/qbluetoothuuid/tst_qbluetoothuuid.cpp
index 6cff5c2e..218c9580 100644
--- a/tests/auto/qbluetoothuuid/tst_qbluetoothuuid.cpp
+++ b/tests/auto/qbluetoothuuid/tst_qbluetoothuuid.cpp
@@ -246,7 +246,7 @@ void tst_QBluetoothUuid::tst_conversion()
if (constructUuid16) {
QBluetoothUuid uuid(uuid16);
- QCOMPARE(uuid, QBluetoothUuid(uuidS));
+ QCOMPARE(uuid, QBluetoothUuid(QStringView{uuidS}));
bool ok;
@@ -268,7 +268,7 @@ void tst_QBluetoothUuid::tst_conversion()
if (constructUuid32) {
QBluetoothUuid uuid(uuid32);
- QCOMPARE(uuid, QBluetoothUuid(uuidS));
+ QCOMPARE(uuid, QBluetoothUuid(QLatin1StringView{uuidS.toLatin1()}));
bool ok;
@@ -293,7 +293,7 @@ void tst_QBluetoothUuid::tst_conversion()
if (constructUuid128) {
QBluetoothUuid uuid(uuid128);
- QCOMPARE(uuid, QBluetoothUuid(uuidS));
+ QCOMPARE(uuid, QBluetoothUuid(QUtf8StringView{uuidS.toUtf8()}));
bool ok;