diff options
author | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2021-05-04 11:13:27 +0200 |
---|---|---|
committer | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2021-05-07 15:15:07 +0200 |
commit | 6d5e8dfafff7fc4ef9269bacd692fb6d93b2bc1f (patch) | |
tree | 54cc73c9f8e00994fcde2370bf3f23dbd1c3c8d7 /src/bluetooth/osx | |
parent | 5466df6f9b9237caba71a3ae323b931de1f7eda9 (diff) |
Backport a fix from Qt 6 (stop using a deprecated API)
Change-Id: I740ecdd2a79bb4011b61e751edba918ea64b249e
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/bluetooth/osx')
-rw-r--r-- | src/bluetooth/osx/osxbtutility.mm | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/bluetooth/osx/osxbtutility.mm b/src/bluetooth/osx/osxbtutility.mm index 861d0395..de1a3044 100644 --- a/src/bluetooth/osx/osxbtutility.mm +++ b/src/bluetooth/osx/osxbtutility.mm @@ -233,11 +233,17 @@ CFStrongReference<CFUUIDRef> cf_uuid(const QBluetoothUuid &qtUuid) ObjCStrongReference<CBUUID> cb_uuid(const QBluetoothUuid &qtUuid) { - CFStrongReference<CFUUIDRef> cfUuid(cf_uuid(qtUuid)); - if (!cfUuid) - return ObjCStrongReference<CBUUID>(); + bool ok = false; + const auto asUInt16 = qToBigEndian(qtUuid.toUInt16(&ok)); + const auto asUInt128 = qtUuid.toUInt128(); - ObjCStrongReference<CBUUID> cbUuid([CBUUID UUIDWithCFUUID:cfUuid], true); //true == retain. + const NSUInteger length = ok ? sizeof asUInt16 : sizeof asUInt128; + const void *bytes = &asUInt128; + if (ok) + bytes = &asUInt16; + + NSData *uuidData = [NSData dataWithBytes:bytes length:length]; + ObjCStrongReference<CBUUID> cbUuid([CBUUID UUIDWithData:uuidData], true); // true == retain. return cbUuid; } |