diff --git a/src/corelib/kernel/qcore_foundation.mm b/src/corelib/kernel/qcore_foundation.mm index a31040944f1..6d2451e078e 100644 --- a/src/corelib/kernel/qcore_foundation.mm +++ b/src/corelib/kernel/qcore_foundation.mm @@ -300,8 +300,8 @@ QUuid QUuid::fromCFUUID(CFUUIDRef uuid) */ CFUUIDRef QUuid::toCFUUID() const { - const QByteArray bytes = toRfc4122(); - return CFUUIDCreateFromUUIDBytes(0, *reinterpret_cast(bytes.constData())); + const auto bytes = toBytes(); + return CFUUIDCreateFromUUIDBytes(0, *reinterpret_cast(&bytes)); } /*! @@ -333,8 +333,11 @@ QUuid QUuid::fromNSUUID(const NSUUID *uuid) */ NSUUID *QUuid::toNSUUID() const { - const QByteArray bytes = toRfc4122(); - return [[[NSUUID alloc] initWithUUIDBytes:*reinterpret_cast(bytes.constData())] autorelease]; + const auto bytes = toBytes(); + static_assert(sizeof bytes == sizeof(uuid_t)); + uuid_t u; + memcpy(&u, &bytes, sizeof(uuid_t)); + return [[[NSUUID alloc] initWithUUIDBytes:u] autorelease]; } // ---------------------------------------------------------------------------- diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp index 42f21eea88c..8c3b758aaca 100644 --- a/src/corelib/plugin/quuid.cpp +++ b/src/corelib/plugin/quuid.cpp @@ -119,7 +119,7 @@ static QUuid _q_uuidFromHex(const char *src) static QUuid createFromName(const QUuid &ns, const QByteArray &baseData, QCryptographicHash::Algorithm algorithm, int version) { QCryptographicHash hash(algorithm); - hash.addData(ns.toRfc4122()); + hash.addData(QByteArrayView{ns.toBytes()}); hash.addData(baseData); QByteArrayView hashResult = hash.resultView(); Q_ASSERT(hashResult.size() >= 16);