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:
Dirk Hohndel 2017-05-06 11:06:18 -07:00
parent 67fbf6009a
commit 38af1f2ab9
3 changed files with 8 additions and 1 deletions

View file

@ -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);