[gnome-maps/gnome-3-38] mapView: Don't store location when view is already disposed



commit f336a28a193384fe7bbc7c8d8e69405212afd3e3
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 a73db407..f9c39cf0 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -590,9 +590,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]