diff options
author | Alex Blasche <alexander.blasche@theqtcompany.com> | 2016-05-31 09:25:06 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@theqtcompany.com> | 2016-06-01 06:28:10 +0000 |
commit | 968e683a59bdaf51ad0d12069ce68c4fad6190a1 (patch) | |
tree | 1663030d385c18db71d7f17bc55848a29cb0597a /src | |
parent | b9aae35fab6a256705fc3e2bd8d001075fc28efa (diff) |
Bluez: Cleanup internal states before sending notifications to API user
The error(), finished() and canceled() signals notify the user about
internal state changes. Signal handlers may call back into the same
class instance that just emitted the signals. If the instance did not
cleanup its internal state then the sudden reentry can cause weird
behavior.
Adds a comment that the pendingCancel & pendingStart behavior is
to be removed in Qt6. It has little advantage and cuases lots of
headaches. Unfortunately all backends exhibit the behavior and
therefore every backend has to change accordingly.
Task-number: QTBUG-51307
Change-Id: Ia5bf9efd0ed27e015361b10499ced069d16a9c93
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp index 18accdf5..47323e85 100644 --- a/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp +++ b/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp @@ -92,12 +92,19 @@ QBluetoothDeviceDiscoveryAgentPrivate::~QBluetoothDeviceDiscoveryAgentPrivate() delete adapterBluez5; } +//TODO: Qt6 remove the pendingCancel/pendingStart logic as it is cumbersome. +// It is a behavior change across all platforms and was initially done +// for Bluez. The behavior should be similar to QBluetoothServiceDiscoveryAgent +// PendingCancel creates issues whereby the agent is still shutting down +// but isActive() below already returns false. This means the isActive() is +// out of sync with the finished() and cancel() signal. + bool QBluetoothDeviceDiscoveryAgentPrivate::isActive() const { if (pendingStart) return true; if (pendingCancel) - return false; + return false; //TODO Qt6: remove pending[Cancel|Start] logic (see comment above) return (adapter || adapterBluez5); } @@ -195,8 +202,8 @@ void QBluetoothDeviceDiscoveryAgentPrivate::start() errorString = discoveryReply.error().message(); lastError = QBluetoothDeviceDiscoveryAgent::InputOutputError; Q_Q(QBluetoothDeviceDiscoveryAgent); - emit q->error(lastError); qCDebug(QT_BT_BLUEZ) << Q_FUNC_INFO << "ERROR: " << errorString; + emit q->error(lastError); return; } } @@ -415,8 +422,8 @@ void QBluetoothDeviceDiscoveryAgentPrivate::_q_propertyChanged(const QString &na adapter->deleteLater(); adapter = 0; - emit q->canceled(); pendingCancel = false; + emit q->canceled(); } else if (pendingStart) { adapter->deleteLater(); adapter = 0; @@ -492,8 +499,8 @@ void QBluetoothDeviceDiscoveryAgentPrivate::_q_discoveryFinished() adapterBluez5 = 0; if (pendingCancel && !pendingStart) { - emit q->canceled(); pendingCancel = false; + emit q->canceled(); } else if (pendingStart) { pendingStart = false; pendingCancel = false; |