summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qbluetoothsocket_winrt.cpp
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@qt.io>2018-08-01 12:48:32 +0200
committerAlex Blasche <alexander.blasche@qt.io>2018-08-09 08:55:08 +0000
commit45c843ceca9fac1aa1246043730eaeeb3ed23235 (patch)
tree81e7e35b768ffa5443a3477fb4943df9f7fc5ec1 /src/bluetooth/qbluetoothsocket_winrt.cpp
parent80bea1f32b92c70c21c96762e31c726cb49e180f (diff)
Shift close/abort signaling from QBluetoothSocket to private implementations
The private implementation can much more easily determine whether the socket closure is already done or not. On Bluez DBus, this avoids disconnected() being emitted twice. Another platform that is still delayed is Android. The patch permits the removal of Android specific ifdefs. Last but not least the patch cleans up missing signals in WinRT. Task-number: QTBUG-68550 Change-Id: I189e1dbc9f6d410522da1a82113fdf4fe79a4cbd Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/bluetooth/qbluetoothsocket_winrt.cpp')
-rw-r--r--src/bluetooth/qbluetoothsocket_winrt.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/bluetooth/qbluetoothsocket_winrt.cpp b/src/bluetooth/qbluetoothsocket_winrt.cpp
index 556d9fc5..f985952a 100644
--- a/src/bluetooth/qbluetoothsocket_winrt.cpp
+++ b/src/bluetooth/qbluetoothsocket_winrt.cpp
@@ -393,7 +393,7 @@ void QBluetoothSocketPrivateWinRT::connectToServiceHelper(const QBluetoothAddres
Q_ASSERT_SUCCEEDED(hr);
q->setSocketState(QBluetoothSocket::ConnectingState);
- q->setOpenMode(openMode);
+ requestedOpenMode = openMode;
QEventDispatcherWinRT::runOnXamlThread([this]() {
HRESULT hr;
hr = m_connectOp->put_Completed(Callback<IAsyncActionCompletedHandler>(
@@ -517,7 +517,14 @@ void QBluetoothSocketPrivateWinRT::abort()
m_socketObject = nullptr;
socket = -1;
}
+
+ const bool wasConnected = q->state() == QBluetoothSocket::ConnectedState;
q->setSocketState(QBluetoothSocket::UnconnectedState);
+ if (wasConnected) {
+ q->setOpenMode(QIODevice::NotOpen);
+ emit q->readChannelFinished();
+ emit q->disconnected();
+ }
}
QString QBluetoothSocketPrivateWinRT::localName() const
@@ -727,7 +734,13 @@ void QBluetoothSocketPrivateWinRT::handleError(QBluetoothSocket::SocketError err
}
q->setSocketError(error);
+ const bool wasConnected = q->state() == QBluetoothSocket::ConnectedState;
q->setSocketState(QBluetoothSocket::UnconnectedState);
+ if (wasConnected) {
+ q->setOpenMode(QIODevice::NotOpen);
+ emit q->readChannelFinished();
+ emit q->disconnected();
+ }
}
void QBluetoothSocketPrivateWinRT::addToPendingData(const QVector<QByteArray> &data)
@@ -794,6 +807,7 @@ HRESULT QBluetoothSocketPrivateWinRT::handleConnectOpFinished(ABI::Windows::Foun
Q_ASSERT_SUCCEEDED(hr);
}
+ q->setOpenMode(requestedOpenMode);
q->setSocketState(QBluetoothSocket::ConnectedState);
m_worker->startReading();
emit q->connected();