summaryrefslogtreecommitdiffstats
path: root/core/btdiscovery.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2019-01-23 14:28:56 +1300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-01-23 14:41:17 +1300
commit2f9bf92a1792cc99afa03190d05d833280ccd881 (patch)
treee47c15057ccac82a4e8ec5fa008ebddc0c62093d /core/btdiscovery.cpp
parent21c81d5b871f5cf36c49e9020511f51a325169fb (diff)
downloadsubsurface-2f9bf92a1792cc99afa03190d05d833280ccd881.tar.gz
Bluetooth: don't crash if BT is turned off
At least on a Mac we can get here without a discoveryAgent if BT is off, so don't derefence the NULL pointer in that case. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/btdiscovery.cpp')
-rw-r--r--core/btdiscovery.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/core/btdiscovery.cpp b/core/btdiscovery.cpp
index b9ef687ac..578264b48 100644
--- a/core/btdiscovery.cpp
+++ b/core/btdiscovery.cpp
@@ -316,6 +316,12 @@ bool BTDiscovery::checkException(const char* method, const QAndroidJniObject *ob
void BTDiscovery::discoverAddress(QString address)
{
+ // if we have a discovery agent, check if we know about the address and if not
+ // make sure we are looking for it
+ // (if we don't have a discoveryAgent then likely BT is off or something else went wrong)
+ if (!discoveryAgent)
+ return;
+
// let's make sure there is no device name mixed in with the address
QString btAddress;
btAddress = extractBluetoothAddress(address);