From 035e08e633e9eb8fa4bc12dec77dc84218747f95 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 27 Aug 2015 09:22:17 -0700 Subject: 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 --- qt-ui/btdeviceselectiondialog.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'qt-ui/btdeviceselectiondialog.cpp') diff --git a/qt-ui/btdeviceselectiondialog.cpp b/qt-ui/btdeviceselectiondialog.cpp index bd7ad1e3d..17ef634bb 100644 --- a/qt-ui/btdeviceselectiondialog.cpp +++ b/qt-ui/btdeviceselectiondialog.cpp @@ -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() -- cgit v1.2.3-70-g09d2