mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 21:33:24 +00:00
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>
This commit is contained in:
parent
67fbf6009a
commit
38af1f2ab9
3 changed files with 8 additions and 1 deletions
|
@ -46,6 +46,11 @@ GpsLocation *GpsLocation::instance()
|
|||
return m_Instance;
|
||||
}
|
||||
|
||||
bool GpsLocation::hasInstance()
|
||||
{
|
||||
return m_Instance != NULL;
|
||||
}
|
||||
|
||||
GpsLocation::~GpsLocation()
|
||||
{
|
||||
m_Instance = NULL;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -398,7 +398,8 @@ SubsurfaceWebServices::SubsurfaceWebServices(QWidget *parent, Qt::WindowFlags f)
|
|||
|
||||
if (userid.isEmpty() &&
|
||||
!same_string(prefs.cloud_storage_email, "") &&
|
||||
!same_string(prefs.cloud_storage_password, ""))
|
||||
!same_string(prefs.cloud_storage_password, "") &&
|
||||
GpsLocation::hasInstance())
|
||||
userid = GpsLocation::instance()->getUserid(prefs.cloud_storage_email, prefs.cloud_storage_password);
|
||||
|
||||
ui.userID->setText(userid);
|
||||
|
|
Loading…
Add table
Reference in a new issue