[gnome-maps/wip/mlundblad/dont-store-invalid-location] mapView: Don't store location when view is already disposed




commit 331c493f729d058e5ac31771b5a04c9fefbaae3d
Author: Marcus Lundblad <ml update uu se>
Date:   Tue Jan 26 22:32:55 2021 +0100

    mapView: Don't store location when view is already disposed
    
    Protect against storing invalid locations when the view
    has already been disposing. This can happen when moving
    the view and immediatly quitting.

 src/mapView.js | 14 ++++++++++++--
 1 file 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() {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]