254 lines
11 KiB
Diff
254 lines
11 KiB
Diff
From daf0e91b5be5a136d93b0e66efc3681f28a2ffde Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Andr=C3=A9=20Klitzing?= <aklitzing@gmail.com>
|
|
Date: Fri, 19 Jul 2019 11:06:59 +0200
|
|
Subject: [PATCH] Core/IO/Bluetooth - fix ambiguous conversions for macOS
|
|
|
|
This is a sibling of QTBUG-76847 on macOS instead of iOS.
|
|
---
|
|
.../qbluetoothdevicediscoveryagent_osx.mm | 6 ++---
|
|
src/bluetooth/qbluetoothlocaldevice_osx.mm | 2 +-
|
|
src/bluetooth/qbluetoothserver_osx.mm | 6 ++---
|
|
src/bluetooth/qbluetoothserviceinfo_osx.mm | 2 +-
|
|
src/bluetooth/qbluetoothsocket_osx.mm | 26 +++++++++----------
|
|
src/bluetooth/qbluetoothtransferreply_osx.mm | 10 +++----
|
|
6 files changed, 26 insertions(+), 26 deletions(-)
|
|
|
|
diff --git x/qtconnectivity/src/bluetooth/qbluetoothdevicediscoveryagent_osx.mm y/qtconnectivity/src/bluetooth/qbluetoothdevicediscoveryagent_osx.mm
|
|
index 4657da82..bdc3c85e 100644
|
|
--- x/qtconnectivity/src/bluetooth/qbluetoothdevicediscoveryagent_osx.mm
|
|
+++ y/qtconnectivity/src/bluetooth/qbluetoothdevicediscoveryagent_osx.mm
|
|
@@ -181,7 +181,7 @@ QBluetoothDeviceDiscoveryAgentPrivate::QBluetoothDeviceDiscoveryAgentPrivate(con
|
|
|
|
QBluetoothDeviceDiscoveryAgentPrivate::~QBluetoothDeviceDiscoveryAgentPrivate()
|
|
{
|
|
- if (inquiryLE && agentState != NonActive) {
|
|
+ if (inquiryLE.data() && agentState != NonActive) {
|
|
// We want the LE scan to stop as soon as possible.
|
|
if (dispatch_queue_t leQueue = OSXBluetooth::qt_LE_queue()) {
|
|
// Local variable to be retained ...
|
|
@@ -195,7 +195,7 @@ QBluetoothDeviceDiscoveryAgentPrivate::~QBluetoothDeviceDiscoveryAgentPrivate()
|
|
|
|
bool QBluetoothDeviceDiscoveryAgentPrivate::isValid() const
|
|
{
|
|
- return hostController && [hostController powerState] == kBluetoothHCIPowerStateON;
|
|
+ return hostController.data() && [hostController powerState] == kBluetoothHCIPowerStateON;
|
|
}
|
|
|
|
bool QBluetoothDeviceDiscoveryAgentPrivate::isActive() const
|
|
@@ -292,7 +292,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::startLE()
|
|
|
|
// Check queue and create scanner:
|
|
inquiryLE.reset([[LEDeviceInquiryObjC alloc] initWithNotifier:notifier.data()]);
|
|
- if (inquiryLE)
|
|
+ if (inquiryLE.data())
|
|
notifier.take(); // Whatever happens next, inquiryLE is already the owner ...
|
|
|
|
dispatch_queue_t leQueue(qt_LE_queue());
|
|
diff --git x/qtconnectivity/src/bluetooth/qbluetoothlocaldevice_osx.mm y/qtconnectivity/src/bluetooth/qbluetoothlocaldevice_osx.mm
|
|
index 52b7bba8..e7dd9906 100644
|
|
--- x/qtconnectivity/src/bluetooth/qbluetoothlocaldevice_osx.mm
|
|
+++ y/qtconnectivity/src/bluetooth/qbluetoothlocaldevice_osx.mm
|
|
@@ -149,7 +149,7 @@ QBluetoothLocalDevicePrivate::QBluetoothLocalDevicePrivate(QBluetoothLocalDevice
|
|
|
|
bool QBluetoothLocalDevicePrivate::isValid() const
|
|
{
|
|
- return hostController;
|
|
+ return hostController.data();
|
|
}
|
|
|
|
void QBluetoothLocalDevicePrivate::requestPairing(const QBluetoothAddress &address, Pairing pairing)
|
|
diff --git x/qtconnectivity/src/bluetooth/qbluetoothserver_osx.mm y/qtconnectivity/src/bluetooth/qbluetoothserver_osx.mm
|
|
index eefaf4da..5d3b8fc4 100644
|
|
--- x/qtconnectivity/src/bluetooth/qbluetoothserver_osx.mm
|
|
+++ y/qtconnectivity/src/bluetooth/qbluetoothserver_osx.mm
|
|
@@ -142,7 +142,7 @@ void QBluetoothServerPrivate::stopListener()
|
|
|
|
void QBluetoothServerPrivate::openNotify(IOBluetoothRFCOMMChannel *channel)
|
|
{
|
|
- Q_ASSERT_X(listener, Q_FUNC_INFO, "invalid listener (nil)");
|
|
+ Q_ASSERT_X(listener.data(), Q_FUNC_INFO, "invalid listener (nil)");
|
|
Q_ASSERT_X(channel, Q_FUNC_INFO, "invalid channel (nil)");
|
|
Q_ASSERT_X(q_ptr, Q_FUNC_INFO, "invalid q_ptr (null)");
|
|
|
|
@@ -154,7 +154,7 @@ void QBluetoothServerPrivate::openNotify(IOBluetoothRFCOMMChannel *channel)
|
|
|
|
void QBluetoothServerPrivate::openNotify(IOBluetoothL2CAPChannel *channel)
|
|
{
|
|
- Q_ASSERT_X(listener, Q_FUNC_INFO, "invalid listener (nil)");
|
|
+ Q_ASSERT_X(listener.data(), Q_FUNC_INFO, "invalid listener (nil)");
|
|
Q_ASSERT_X(channel, Q_FUNC_INFO, "invalid channel (nil)");
|
|
Q_ASSERT_X(q_ptr, Q_FUNC_INFO, "invalid q_ptr (null)");
|
|
|
|
@@ -293,7 +293,7 @@ bool QBluetoothServer::listen(const QBluetoothAddress &address, quint16 port)
|
|
|
|
OSXBluetooth::qt_test_iobluetooth_runloop();
|
|
|
|
- if (d_ptr->listener) {
|
|
+ if (d_ptr->listener.data()) {
|
|
qCWarning(QT_BT_OSX) << "already in listen mode, close server first";
|
|
return false;
|
|
}
|
|
diff --git x/qtconnectivity/src/bluetooth/qbluetoothserviceinfo_osx.mm y/qtconnectivity/src/bluetooth/qbluetoothserviceinfo_osx.mm
|
|
index 34de4695..7ce4c645 100644
|
|
--- x/qtconnectivity/src/bluetooth/qbluetoothserviceinfo_osx.mm
|
|
+++ y/qtconnectivity/src/bluetooth/qbluetoothserviceinfo_osx.mm
|
|
@@ -152,7 +152,7 @@ bool QBluetoothServiceInfoPrivate::unregisterService()
|
|
if (!registered)
|
|
return false;
|
|
|
|
- Q_ASSERT_X(serviceRecord, Q_FUNC_INFO, "service registered, but serviceRecord is nil");
|
|
+ Q_ASSERT_X(serviceRecord.data(), Q_FUNC_INFO, "service registered, but serviceRecord is nil");
|
|
|
|
[serviceRecord removeServiceRecord];
|
|
serviceRecord.reset(nil);
|
|
diff --git x/qtconnectivity/src/bluetooth/qbluetoothsocket_osx.mm y/qtconnectivity/src/bluetooth/qbluetoothsocket_osx.mm
|
|
index 7f630146..2a856092 100644
|
|
--- x/qtconnectivity/src/bluetooth/qbluetoothsocket_osx.mm
|
|
+++ y/qtconnectivity/src/bluetooth/qbluetoothsocket_osx.mm
|
|
@@ -101,13 +101,13 @@ void QBluetoothSocketPrivate::connectToService(const QBluetoothAddress &address,
|
|
|
|
if (socketType == QBluetoothServiceInfo::RfcommProtocol) {
|
|
rfcommChannel.reset([[ObjCRFCOMMChannel alloc] initWithDelegate:this]);
|
|
- if (rfcommChannel)
|
|
+ if (rfcommChannel.data())
|
|
status = [rfcommChannel connectAsyncToDevice:address withChannelID:port];
|
|
else
|
|
status = kIOReturnNoMemory;
|
|
} else if (socketType == QBluetoothServiceInfo::L2capProtocol) {
|
|
l2capChannel.reset([[ObjCL2CAPChannel alloc] initWithDelegate:this]);
|
|
- if (l2capChannel)
|
|
+ if (l2capChannel.data())
|
|
status = [l2capChannel connectAsyncToDevice:address withPSM:port];
|
|
else
|
|
status = kIOReturnNoMemory;
|
|
@@ -181,10 +181,10 @@ QString QBluetoothSocketPrivate::peerName() const
|
|
|
|
NSString *nsName = nil;
|
|
if (socketType == QBluetoothServiceInfo::RfcommProtocol) {
|
|
- if (rfcommChannel)
|
|
+ if (rfcommChannel.data())
|
|
nsName = [rfcommChannel peerName];
|
|
} else if (socketType == QBluetoothServiceInfo::L2capProtocol) {
|
|
- if (l2capChannel)
|
|
+ if (l2capChannel.data())
|
|
nsName = [l2capChannel peerName];
|
|
}
|
|
|
|
@@ -198,10 +198,10 @@ QBluetoothAddress QBluetoothSocketPrivate::peerAddress() const
|
|
{
|
|
BluetoothDeviceAddress addr = {};
|
|
if (socketType == QBluetoothServiceInfo::RfcommProtocol) {
|
|
- if (rfcommChannel)
|
|
+ if (rfcommChannel.data())
|
|
addr = [rfcommChannel peerAddress];
|
|
} else if (socketType == QBluetoothServiceInfo::L2capProtocol) {
|
|
- if (l2capChannel)
|
|
+ if (l2capChannel.data())
|
|
addr = [l2capChannel peerAddress];
|
|
}
|
|
|
|
@@ -211,10 +211,10 @@ QBluetoothAddress QBluetoothSocketPrivate::peerAddress() const
|
|
quint16 QBluetoothSocketPrivate::peerPort() const
|
|
{
|
|
if (socketType == QBluetoothServiceInfo::RfcommProtocol) {
|
|
- if (rfcommChannel)
|
|
+ if (rfcommChannel.data())
|
|
return [rfcommChannel getChannelID];
|
|
} else if (socketType == QBluetoothServiceInfo::L2capProtocol) {
|
|
- if (l2capChannel)
|
|
+ if (l2capChannel.data())
|
|
return [l2capChannel getPSM];
|
|
}
|
|
|
|
@@ -231,7 +231,7 @@ void QBluetoothSocketPrivate::_q_writeNotify()
|
|
Q_ASSERT_X(socketType == QBluetoothServiceInfo::L2capProtocol
|
|
|| socketType == QBluetoothServiceInfo::RfcommProtocol,
|
|
Q_FUNC_INFO, "invalid socket type");
|
|
- Q_ASSERT_X(l2capChannel || rfcommChannel, Q_FUNC_INFO,
|
|
+ Q_ASSERT_X(l2capChannel.data() || rfcommChannel.data(), Q_FUNC_INFO,
|
|
"invalid socket (no open channel)");
|
|
Q_ASSERT_X(q_ptr, Q_FUNC_INFO, "invalid q_ptr (null)");
|
|
|
|
@@ -275,13 +275,13 @@ bool QBluetoothSocketPrivate::setChannel(IOBluetoothRFCOMMChannel *channel)
|
|
|
|
openMode = QIODevice::ReadWrite;
|
|
rfcommChannel.reset([[ObjCRFCOMMChannel alloc] initWithDelegate:this channel:channel]);
|
|
- if (rfcommChannel) {// We do not handle errors, up to an external user.
|
|
+ if (rfcommChannel.data()) {// We do not handle errors, up to an external user.
|
|
q_ptr->setOpenMode(QIODevice::ReadWrite);
|
|
state = QBluetoothSocket::ConnectedState;
|
|
socketType = QBluetoothServiceInfo::RfcommProtocol;
|
|
}
|
|
|
|
- return rfcommChannel;
|
|
+ return rfcommChannel.data();
|
|
}
|
|
|
|
bool QBluetoothSocketPrivate::setChannel(IOBluetoothL2CAPChannel *channel)
|
|
@@ -299,13 +299,13 @@ bool QBluetoothSocketPrivate::setChannel(IOBluetoothL2CAPChannel *channel)
|
|
|
|
openMode = QIODevice::ReadWrite;
|
|
l2capChannel.reset([[ObjCL2CAPChannel alloc] initWithDelegate:this channel:channel]);
|
|
- if (l2capChannel) {// We do not handle errors, up to an external user.
|
|
+ if (l2capChannel.data()) {// We do not handle errors, up to an external user.
|
|
q_ptr->setOpenMode(QIODevice::ReadWrite);
|
|
state = QBluetoothSocket::ConnectedState;
|
|
socketType = QBluetoothServiceInfo::L2capProtocol;
|
|
}
|
|
|
|
- return l2capChannel;
|
|
+ return l2capChannel.data();
|
|
}
|
|
|
|
|
|
diff --git x/qtconnectivity/src/bluetooth/qbluetoothtransferreply_osx.mm y/qtconnectivity/src/bluetooth/qbluetoothtransferreply_osx.mm
|
|
index 65c8f82d..40a747f8 100644
|
|
--- x/qtconnectivity/src/bluetooth/qbluetoothtransferreply_osx.mm
|
|
+++ y/qtconnectivity/src/bluetooth/qbluetoothtransferreply_osx.mm
|
|
@@ -136,13 +136,13 @@ QBluetoothTransferReplyOSXPrivate::~QBluetoothTransferReplyOSXPrivate()
|
|
// The OBEX session will be closed then. If
|
|
// somehow IOBluetooth/OBEX still has a reference to our
|
|
// session, it will not call any of delegate's callbacks.
|
|
- if (session)
|
|
+ if (session.data())
|
|
[session closeSession];
|
|
}
|
|
|
|
bool QBluetoothTransferReplyOSXPrivate::isActive() const
|
|
{
|
|
- return agent || (session && [session hasActiveRequest]);
|
|
+ return agent.data() || (session.data() && [session hasActiveRequest]);
|
|
}
|
|
|
|
bool QBluetoothTransferReplyOSXPrivate::startOPP(const QBluetoothAddress &device)
|
|
@@ -218,7 +218,7 @@ void QBluetoothTransferReplyOSXPrivate::sendConnect(const QBluetoothAddress &dev
|
|
void QBluetoothTransferReplyOSXPrivate::sendPut()
|
|
{
|
|
Q_ASSERT_X(inputStream, Q_FUNC_INFO, "invalid input stream (null)");
|
|
- Q_ASSERT_X(session, Q_FUNC_INFO, "invalid OBEX session (nil)");
|
|
+ Q_ASSERT_X(session.data(), Q_FUNC_INFO, "invalid OBEX session (nil)");
|
|
Q_ASSERT_X([session isConnected], Q_FUNC_INFO, "not connected");
|
|
Q_ASSERT_X(![session hasActiveRequest], Q_FUNC_INFO,
|
|
"session already has an active request");
|
|
@@ -268,7 +268,7 @@ void QBluetoothTransferReplyOSXPrivate::OBEXConnectError(OBEXError errorCode, OB
|
|
Q_UNUSED(errorCode)
|
|
Q_UNUSED(response)
|
|
|
|
- if (session) {
|
|
+ if (session.data()) {
|
|
setReplyError(QBluetoothTransferReply::SessionError,
|
|
QCoreApplication::translate(TRANSFER_REPLY, TR_CONNECT_FAILED));
|
|
} else {
|
|
@@ -283,7 +283,7 @@ void QBluetoothTransferReplyOSXPrivate::OBEXConnectError(OBEXError errorCode, OB
|
|
void QBluetoothTransferReplyOSXPrivate::OBEXConnectSuccess()
|
|
{
|
|
// Now that OBEX connect succeeded, we can send an OBEX put request.
|
|
- if (!session) {
|
|
+ if (!session.data()) {
|
|
// We're still in OBEXConnect(), it'll take care of next steps.
|
|
return;
|
|
}
|
|
--
|
|
2.22.0
|
|
|