[gnome-maps] userLocationMarker: Don't connect to destroy



commit b763a3358129bc5482bd987ddf90c4d53477b132
Author: Marcus Lundblad <ml update uu se>
Date:   Sun Mar 12 22:30:43 2017 +0100

    userLocationMarker: Don't connect to destroy
    
    Instead of connecting to the destoy signal to disconnect from the
    MapView zoom-level property, explicitly disconnect the signal handler
    when re-creating the marker in the MapView.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=779874

 src/mapView.js            |    2 ++
 src/userLocationMarker.js |    8 +++++---
 2 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/src/mapView.js b/src/mapView.js
index 2658b3e..a1942df 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -433,6 +433,8 @@ const MapView = new Lang.Class({
         let place = Application.geoclue.place;
 
         let previousSelected = this._userLocation && this._userLocation.selected;
+        if (this._userLocation)
+            this._userLocation.disconnectView();
         this._userLocation = new UserLocationMarker.UserLocationMarker({ place: place,
                                                                          mapView: this });
         this._userLocationLayer.remove_all();
diff --git a/src/userLocationMarker.js b/src/userLocationMarker.js
index 0db4906..c891fa8 100644
--- a/src/userLocationMarker.js
+++ b/src/userLocationMarker.js
@@ -83,9 +83,6 @@ const UserLocationMarker = new Lang.Class({
             this._accuracyMarker.refreshGeometry(this._view);
             this._zoomLevelId = this._view.connect('notify::zoom-level',
                                                    
this._accuracyMarker.refreshGeometry.bind(this._accuracyMarker));
-            this.connect('destroy', (function() {
-                this._view.disconnect(this._zoomLevelId);
-            }).bind(this));
         }
     },
 
@@ -104,5 +101,10 @@ const UserLocationMarker = new Lang.Class({
             layer.add_marker(this._accuracyMarker);
 
         layer.add_marker(this);
+    },
+
+    disconnectView: function() {
+        if (this._zoomLevelId)
+            this._view.disconnect(this._zoomLevelId);
     }
 });


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