Wait for BTH device discovery thread to finish on stop call

We should wait for the WinBluetoothDeviceDiscoveryAgent completion
when the stop method was called.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Claudiu Olteanu 2015-08-18 22:16:29 +03:00 committed by Dirk Hohndel
parent 74187657e5
commit c0b169e0a3

View file

@ -93,8 +93,12 @@ BtDeviceSelectionDialog::~BtDeviceSelectionDialog()
delete localDevice;
#endif
// Clean the device discovery agent
if (remoteDeviceDiscoveryAgent->isActive())
if (remoteDeviceDiscoveryAgent->isActive()) {
remoteDeviceDiscoveryAgent->stop();
#if defined(Q_OS_WIN)
remoteDeviceDiscoveryAgent->wait();
#endif
}
delete remoteDeviceDiscoveryAgent;
}
@ -126,6 +130,9 @@ void BtDeviceSelectionDialog::on_save_clicked()
if (remoteDeviceDiscoveryAgent->isActive()) {
// Stop the SDP agent if the clear button is pressed and enable the Scan button
remoteDeviceDiscoveryAgent->stop();
#if defined(Q_OS_WIN)
remoteDeviceDiscoveryAgent->wait();
#endif
ui->scan->setEnabled(true);
}
@ -142,6 +149,9 @@ void BtDeviceSelectionDialog::on_clear_clicked()
if (remoteDeviceDiscoveryAgent->isActive()) {
// Stop the SDP agent if the clear button is pressed and enable the Scan button
remoteDeviceDiscoveryAgent->stop();
#if defined(Q_OS_WIN)
remoteDeviceDiscoveryAgent->wait();
#endif
ui->scan->setEnabled(true);
}
}