diff options
author | Marcus Lundblad <ml@update.uu.se> | 2021-01-26 22:32:55 +0100 |
---|---|---|
committer | Marcus Lundblad <ml@update.uu.se> | 2021-01-26 22:32:55 +0100 |
commit | 331c493f729d058e5ac31771b5a04c9fefbaae3d (patch) | |
tree | 754b0d844ea60d32fc9f1fc4f5f13d0337cd4c6b | |
parent | 9cefa3f72e3c89b63b2069d52bebd07970390c12 (diff) | |
download | gnome-maps-wip/mlundblad/dont-store-invalid-location.tar.gz |
mapView: Don't store location when view is already disposedwip/mlundblad/dont-store-invalid-location
Protect against storing invalid locations when the view
has already been disposing. This can happen when moving
the view and immediatly quitting.
-rw-r--r-- | src/mapView.js | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/mapView.js b/src/mapView.js index f4b72d92..60bf1785 100644 --- a/src/mapView.js +++ b/src/mapView.js @@ -647,9 +647,19 @@ var MapView = GObject.registerClass({ } _storeLocation() { - Application.settings.set('zoom-level', this.view.zoom_level); + let zoom = this.view.zoom_level; let location = [this.view.latitude, this.view.longitude]; - Application.settings.set('last-viewed-location', location); + + /* protect agains situations where the Champlain view was already + * disposed, in this case zoom will be set to the GObject property + * getter + */ + if (!isNaN(zoom)) { + Application.settings.set('zoom-level', zoom); + Application.settings.set('last-viewed-location', location); + } else { + Utils.debug('Failed to extract location to store'); + } } _goToStoredLocation() { |