diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2017-05-06 11:06:18 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-05-06 11:12:07 -0700 |
commit | 38af1f2ab93f2ed20552b0869a02844778138739 (patch) | |
tree | 3de4dccd977b9cdf023bf5ba329a97312097eb08 /core | |
parent | 67fbf6009a36233d6621e4f40002fc016a464404 (diff) | |
download | subsurface-38af1f2ab93f2ed20552b0869a02844778138739.tar.gz |
Check if we have an instance before dereferencing it
If we don't have a GPS service userid in the preferences and the GpsLocation class
isn't instantiated, this would cause a crash.
Fixes #367
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core')
-rw-r--r-- | core/gpslocation.cpp | 5 | ||||
-rw-r--r-- | core/gpslocation.h | 1 |
2 files changed, 6 insertions, 0 deletions
diff --git a/core/gpslocation.cpp b/core/gpslocation.cpp index 1c5d378cf..30b101419 100644 --- a/core/gpslocation.cpp +++ b/core/gpslocation.cpp @@ -46,6 +46,11 @@ GpsLocation *GpsLocation::instance() return m_Instance; } +bool GpsLocation::hasInstance() +{ + return m_Instance != NULL; +} + GpsLocation::~GpsLocation() { m_Instance = NULL; diff --git a/core/gpslocation.h b/core/gpslocation.h index 34e0708ff..9922997f1 100644 --- a/core/gpslocation.h +++ b/core/gpslocation.h @@ -27,6 +27,7 @@ public: GpsLocation(void (*showMsgCB)(const char *msg), QObject *parent); ~GpsLocation(); static GpsLocation *instance(); + static bool hasInstance(); bool applyLocations(); int getGpsNum() const; QString getUserid(QString user, QString passwd); |