summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qlowenergycontroller_bluez.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-10-30 08:43:34 +0100
committerLiang Qi <liang.qi@qt.io>2017-10-30 08:43:34 +0100
commit3c29e286c7e79a3704a849e05e47d17d6a7cf62c (patch)
treec1b9a0d03714f22497acce77c1e7efe0714ff190 /src/bluetooth/qlowenergycontroller_bluez.cpp
parent013ad0570844975cd5c72a77d1cfefa30c3ea656 (diff)
parent6029bad7d1007aecd155985ba13d6c23a01015b8 (diff)
Merge remote-tracking branch 'origin/5.9' into 5.10
Diffstat (limited to 'src/bluetooth/qlowenergycontroller_bluez.cpp')
-rw-r--r--src/bluetooth/qlowenergycontroller_bluez.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/bluetooth/qlowenergycontroller_bluez.cpp b/src/bluetooth/qlowenergycontroller_bluez.cpp
index ca3f7760..003aff38 100644
--- a/src/bluetooth/qlowenergycontroller_bluez.cpp
+++ b/src/bluetooth/qlowenergycontroller_bluez.cpp
@@ -527,8 +527,10 @@ void QLowEnergyControllerPrivate::connectToDevice()
}
setState(QLowEnergyController::ConnectingState);
- if (l2cpSocket)
+ if (l2cpSocket) {
delete l2cpSocket;
+ l2cpSocket = nullptr;
+ }
createServicesForCentralIfRequired();
@@ -581,6 +583,7 @@ void QLowEnergyControllerPrivate::activeConnectionTerminationDone()
qCWarning(QT_BT_BLUEZ) << "Cannot close pending external BTLE connections. Aborting connect attempt";
setError(QLowEnergyController::ConnectionError);
setState(QLowEnergyController::UnconnectedState);
+ l2cpDisconnected();
return;
} else {
establishL2cpClientSocket();
@@ -726,8 +729,16 @@ void QLowEnergyControllerPrivate::l2cpConnected()
void QLowEnergyControllerPrivate::disconnectFromDevice()
{
setState(QLowEnergyController::ClosingState);
- l2cpSocket->close();
+ if (l2cpSocket)
+ l2cpSocket->close();
resetController();
+
+ // this may happen when RemoteDeviceManager::JobType::JobDisconnectDevice
+ // is pending.
+ if (!l2cpSocket) {
+ qWarning(QT_BT_BLUEZ) << "Unexpected closure of device. Cleaning up internal states.";
+ l2cpDisconnected();
+ }
}
void QLowEnergyControllerPrivate::l2cpDisconnected()