diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp index b446edbc95..2a2f4cb00d 100644 --- a/src/corelib/plugin/quuid.cpp +++ b/src/corelib/plugin/quuid.cpp @@ -310,19 +310,6 @@ static QUuid createFromName(const QUuid &ns, const QByteArray &baseData, QCrypto \sa fromBytes(), toBytes(), toRfc4122(), toUInt128() */ -/*! - \fn QUuid::QUuid(quint128 uuid, QSysInfo::Endian order) noexcept - \since 6.6 - - Creates a QUuid based on the integral \a uuid parameter and respecting the - byte order \a order. - - \note This function is only present on platforms that offer a 128-bit - integer type. - - \sa toUInt128(), fromUInt128(), fromBytes(), toBytes(), toRfc4122() -*/ - /*! \fn QUuid::fromUInt128(quint128 uuid, QSysInfo::Endian order) noexcept \since 6.6 diff --git a/src/corelib/plugin/quuid.h b/src/corelib/plugin/quuid.h index 2f1927afa2..140f20a80e 100644 --- a/src/corelib/plugin/quuid.h +++ b/src/corelib/plugin/quuid.h @@ -101,9 +101,7 @@ public: bool isNull() const noexcept; #ifdef QT_SUPPORTS_INT128 - constexpr explicit QUuid(quint128 uuid, QSysInfo::Endian order = QSysInfo::BigEndian) noexcept; - static constexpr QUuid fromUInt128(quint128 uuid, QSysInfo::Endian order = QSysInfo::BigEndian) noexcept - { return QUuid{uuid, order}; } + static constexpr QUuid fromUInt128(quint128 uuid, QSysInfo::Endian order = QSysInfo::BigEndian) noexcept; constexpr quint128 toUInt128(QSysInfo::Endian order = QSysInfo::BigEndian) const noexcept; #endif @@ -245,22 +243,23 @@ inline QUuid QUuid::fromBytes(const void *bytes, QSysInfo::Endian order) noexcep } #ifdef QT_SUPPORTS_INT128 -constexpr QUuid::QUuid(quint128 uuid, QSysInfo::Endian order) noexcept - : QUuid() +constexpr QUuid QUuid::fromUInt128(quint128 uuid, QSysInfo::Endian order) noexcept { + QUuid result = {}; if (order == QSysInfo::BigEndian) { - data1 = qFromBigEndian(int(uuid)); - data2 = qFromBigEndian(ushort(uuid >> 32)); - data3 = qFromBigEndian(ushort(uuid >> 48)); + result.data1 = qFromBigEndian(int(uuid)); + result.data2 = qFromBigEndian(ushort(uuid >> 32)); + result.data3 = qFromBigEndian(ushort(uuid >> 48)); for (int i = 0; i < 8; ++i) - data4[i] = uchar(uuid >> (64 + i * 8)); + result.data4[i] = uchar(uuid >> (64 + i * 8)); } else { - data1 = qFromLittleEndian(uint(uuid >> 96)); - data2 = qFromLittleEndian(ushort(uuid >> 80)); - data3 = qFromLittleEndian(ushort(uuid >> 64)); + result.data1 = qFromLittleEndian(uint(uuid >> 96)); + result.data2 = qFromLittleEndian(ushort(uuid >> 80)); + result.data3 = qFromLittleEndian(ushort(uuid >> 64)); for (int i = 0; i < 8; ++i) - data4[i] = uchar(uuid >> (56 - i * 8)); + result.data4[i] = uchar(uuid >> (56 - i * 8)); } + return result; } constexpr quint128 QUuid::toUInt128(QSysInfo::Endian order) const noexcept diff --git a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp index 08f548a834..80924daa60 100644 --- a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp +++ b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp @@ -252,7 +252,7 @@ void tst_QUuid::uint128() constexpr quint128 u = quint128(Q_UINT64_C(0xfc69b59ecc344436)) << 64 | Q_UINT64_C(0xa43cee95d128b8c5); // This is LE constexpr quint128 be = qToBigEndian(u); - constexpr QUuid uuid(be); + constexpr QUuid uuid = QUuid::fromUInt128(be); static_assert(uuid.toUInt128() == be, "Round-trip through QUuid failed"); QCOMPARE(uuid, uuidA); @@ -262,7 +262,7 @@ void tst_QUuid::uint128() quint128 le = qFromBigEndian(be); QCOMPARE(quint64(uuid.toUInt128(QSysInfo::LittleEndian) >> 64), quint64(le >> 64)); QCOMPARE(quint64(uuid.toUInt128(QSysInfo::LittleEndian)), quint64(le)); - QCOMPARE(QUuid(le, QSysInfo::LittleEndian), uuidA); + QCOMPARE(QUuid::fromUInt128(le, QSysInfo::LittleEndian), uuidA); QUuid::Id128Bytes bytes = { .data128 = { qToBigEndian(u) } }; QUuid uuid2(bytes);