From 687ec9eb370e9538264280b58bed4d3b1c889579 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Wed, 2 Aug 2017 11:53:54 +0200 Subject: Avoid recursion during QBluetoothDeviceDiscoveryAgent::stop() QBluetoothDeviceDiscoveryAgent (DDA) is deleted by QBluetoothServiceDiscoveryAgent (SDA) once it receives an error or SDA is instructed to stop() the discovery process. Currently, this triggers at least two calls to the DDA's stop() function. In addition, if stop() generates an error the error call itself will call back to DDA:stop(). Therefore it create an endless loop back. This is at least true for the Android devices mentioned in the related bug report. This patch ensures that the main logic of Android's DDA::stop() is not called more than once. Further more SDA disconnects from DDA's signals to avoid a potential endless loop. Any error in DDA is not of relevance to the surrounding SDA instance anymore. Task-number: QTBUG-60131 Change-Id: I1df16f2b0896928833aa2ced75c43d4642b4fba3 Reviewed-by: Timur Pocheptsov --- src/bluetooth/qbluetoothservicediscoveryagent.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/bluetooth/qbluetoothservicediscoveryagent.cpp') diff --git a/src/bluetooth/qbluetoothservicediscoveryagent.cpp b/src/bluetooth/qbluetoothservicediscoveryagent.cpp index 7daab4b7..d6163f0e 100644 --- a/src/bluetooth/qbluetoothservicediscoveryagent.cpp +++ b/src/bluetooth/qbluetoothservicediscoveryagent.cpp @@ -450,6 +450,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::startDeviceDiscovery() */ void QBluetoothServiceDiscoveryAgentPrivate::stopDeviceDiscovery() { + // disconnect to avoid recursion during stop() - QTBUG-60131 + // we don't care about a potential signals from device discovery agent anymore + deviceDiscoveryAgent->disconnect(); + deviceDiscoveryAgent->stop(); delete deviceDiscoveryAgent; deviceDiscoveryAgent = 0; @@ -497,6 +501,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_deviceDiscoveryError(QBluetoothD error = static_cast(newError); errorString = deviceDiscoveryAgent->errorString(); + // disconnect to avoid recursion during stop() - QTBUG-60131 + // we don't care about a potential signals from device discovery agent anymore + deviceDiscoveryAgent->disconnect(); + deviceDiscoveryAgent->stop(); delete deviceDiscoveryAgent; deviceDiscoveryAgent = 0; -- cgit v1.2.3