diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2019-09-27 16:26:54 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-09-27 16:26:58 -0700 |
commit | 9ae7040a91c3e3e0606d7abe085ef6da47efd6d2 (patch) | |
tree | de120b115df95fb96d945581aca41cd8c760263c /core/gpslocation.cpp | |
parent | 400b218f769320221567b7b66f39c33126a7d2e1 (diff) | |
download | subsurface-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/gpslocation.cpp')
-rw-r--r-- | core/gpslocation.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/core/gpslocation.cpp b/core/gpslocation.cpp index e18e46321..c5b81e024 100644 --- a/core/gpslocation.cpp +++ b/core/gpslocation.cpp @@ -15,12 +15,16 @@ #include <QApplication> #include <QTimer> +GpsLocation *GpsLocation::m_Instance = NULL; + GpsLocation::GpsLocation(void (*showMsgCB)(const char *), QObject *parent) : QObject(parent), m_GpsSource(0), waitingForPosition(false), haveSource(UNKNOWN) { + Q_ASSERT_X(m_Instance == NULL, "GpsLocation", "GpsLocation recreated"); + m_Instance = this; showMessageCB = showMsgCB; // create a QSettings object that's separate from the main application settings geoSettings = new QSettings(QSettings::NativeFormat, QSettings::UserScope, @@ -33,6 +37,23 @@ GpsLocation::GpsLocation(void (*showMsgCB)(const char *), QObject *parent) : connect(qPrefLocationService::instance(), SIGNAL(time_thresholdChanged(int)), this, SLOT(setGpsTimeThreshold(int))); } +GpsLocation *GpsLocation::instance() +{ + Q_ASSERT(m_Instance != NULL); + + return m_Instance; +} + +bool GpsLocation::hasInstance() +{ + return m_Instance != NULL; +} + +GpsLocation::~GpsLocation() +{ + m_Instance = NULL; +} + void GpsLocation::setGpsTimeThreshold(int seconds) { if (m_GpsSource) { |