QtBT: avoid crash at exit if no BT device found

If localDevice isn't valid we never initialize the discory agent, so
let's not dereference it in the destructor unless it is valid.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2015-08-27 09:22:17 -07:00
parent 837daa08ea
commit 035e08e633

View file

@ -8,7 +8,8 @@
BtDeviceSelectionDialog::BtDeviceSelectionDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::BtDeviceSelectionDialog)
ui(new Ui::BtDeviceSelectionDialog),
remoteDeviceDiscoveryAgent(0)
{
ui->setupUi(this);
@ -92,15 +93,17 @@ BtDeviceSelectionDialog::~BtDeviceSelectionDialog()
// Clean the local device
delete localDevice;
#endif
// Clean the device discovery agent
if (remoteDeviceDiscoveryAgent->isActive()) {
remoteDeviceDiscoveryAgent->stop();
if (remoteDeviceDiscoveryAgent) {
// Clean the device discovery agent
if (remoteDeviceDiscoveryAgent->isActive()) {
remoteDeviceDiscoveryAgent->stop();
#if defined(Q_OS_WIN)
remoteDeviceDiscoveryAgent->wait();
remoteDeviceDiscoveryAgent->wait();
#endif
}
}
delete remoteDeviceDiscoveryAgent;
delete remoteDeviceDiscoveryAgent;
}
}
void BtDeviceSelectionDialog::on_changeDeviceState_clicked()