summaryrefslogtreecommitdiffstats
path: root/core/btdiscovery.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2019-09-27 16:26:54 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-09-27 16:26:58 -0700
commit9ae7040a91c3e3e0606d7abe085ef6da47efd6d2 (patch)
treede120b115df95fb96d945581aca41cd8c760263c /core/btdiscovery.cpp
parent400b218f769320221567b7b66f39c33126a7d2e1 (diff)
downloadsubsurface-9ae7040a91c3e3e0606d7abe085ef6da47efd6d2.tar.gz
Revert the singleton PR
It turns out that this isn't working the way it was intended to. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/btdiscovery.cpp')
-rw-r--r--core/btdiscovery.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/core/btdiscovery.cpp b/core/btdiscovery.cpp
index 1387be400..8db1e02cc 100644
--- a/core/btdiscovery.cpp
+++ b/core/btdiscovery.cpp
@@ -15,6 +15,7 @@ extern QMap<QString, dc_descriptor_t *> descriptorLookup;
namespace {
QHash<QString, QBluetoothDeviceInfo> btDeviceInfo;
}
+BTDiscovery *BTDiscovery::m_instance = NULL;
static dc_descriptor_t *getDeviceType(QString btName)
// central function to convert a BT name to a Subsurface known vendor/model pair
@@ -138,6 +139,11 @@ BTDiscovery::BTDiscovery(QObject*) : m_btValid(false),
m_showNonDiveComputers(false),
discoveryAgent(nullptr)
{
+ if (m_instance) {
+ qDebug() << "trying to create an additional BTDiscovery object";
+ return;
+ }
+ m_instance = this;
#if defined(BT_SUPPORT)
QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
BTDiscoveryReDiscover();
@@ -196,11 +202,19 @@ void BTDiscovery::BTDiscoveryReDiscover()
BTDiscovery::~BTDiscovery()
{
+ m_instance = NULL;
#if defined(BT_SUPPORT)
delete discoveryAgent;
#endif
}
+BTDiscovery *BTDiscovery::instance()
+{
+ if (!m_instance)
+ m_instance = new BTDiscovery();
+ return m_instance;
+}
+
#if defined(BT_SUPPORT)
extern void addBtUuid(QBluetoothUuid uuid);
extern QHash<QString, QStringList> productList;