From b7bb9b417775b6ef69c7c865144d857fd00bb506 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Thu, 28 Jun 2018 08:04:53 +0200 Subject: Bluetooth: don't call deviceDiscoveryError() on scan finished In the remoteDeviceScanFinished slot, the old code called into the deviceDiscoveryError() in case the device discovery agent had the error flag set. This is not necessary, since the agent will send an error signal in such a case. For Qt's device discovery agent, the whole check-for-error is unnecessary, as the documentation states: "The signal is not going to be emitted if the device discovery finishes with an error." But for the homebrew WinBluetoothDeviceDiscoveryAgent, which derives from QThread, both an error() *and* a finished() signal will be sent. Therefore keep the test, but don't call into the slot twice. Signed-off-by: Berthold Stoeger --- desktop-widgets/btdeviceselectiondialog.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'desktop-widgets') diff --git a/desktop-widgets/btdeviceselectiondialog.cpp b/desktop-widgets/btdeviceselectiondialog.cpp index 8077298f6..62558465f 100644 --- a/desktop-widgets/btdeviceselectiondialog.cpp +++ b/desktop-widgets/btdeviceselectiondialog.cpp @@ -194,11 +194,12 @@ void BtDeviceSelectionDialog::on_scan_clicked() void BtDeviceSelectionDialog::remoteDeviceScanFinished() { - if (remoteDeviceDiscoveryAgent->error() == QBluetoothDeviceDiscoveryAgent::NoError) { + // This check is not necessary for Qt's QBluetoothDeviceDiscoveryAgent, + // but with the home-brew WinBluetoothDeviceDiscoveryAgent, on error we + // get an error() and an finished() signal. Thus, don't overwrite the + // error message with a success message. + if (remoteDeviceDiscoveryAgent->error() == QBluetoothDeviceDiscoveryAgent::NoError) ui->dialogStatus->setText(tr("Scanning finished successfully.")); - } else { - deviceDiscoveryError(remoteDeviceDiscoveryAgent->error()); - } ui->scan->setEnabled(true); } -- cgit v1.2.3-70-g09d2