[gnome-weather] city, world: don't use a destroy vfunc



commit bc2036019a29db52c031303a920dd93029979cb0
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Mon Feb 3 19:19:09 2014 +0100

    city, world: don't use a destroy vfunc
    
    We can't have JS code running when JS object is finalized, so
    we need a signal (that will be disconnected the first time
    it's fired)

 src/city.js  |    6 +++---
 src/world.js |    6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/src/city.js b/src/city.js
index e98e393..243a3f1 100644
--- a/src/city.js
+++ b/src/city.js
@@ -140,6 +140,8 @@ const WeatherView = new Lang.Class({
 
         this._info = null;
         this._updateId = 0;
+
+        this.connect('destroy', Lang.bind(this, this._onDestroy));
     },
 
     get info() {
@@ -164,13 +166,11 @@ const WeatherView = new Lang.Class({
         }
     },
 
-    vfunc_destroy: function() {
+    _onDestroy: function() {
         if (this._updateId) {
             this._info.disconnect(this._updateId);
             this._updateId = 0;
         }
-
-        this.parent();
     },
 
     update: function() {
diff --git a/src/world.js b/src/world.js
index 20c07e7..589df98 100644
--- a/src/world.js
+++ b/src/world.js
@@ -277,13 +277,15 @@ const WorldContentView = new Lang.Class({
         else
             this.add(this._placeHolder);
         this._empty = !ok;
+
+        this.connect('destroy', Lang.bind(this, this._onDestroy));
     },
 
     get empty() {
         return this._empty;
     },
 
-    vfunc_destroy: function() {
+    _onDestroy: function() {
         if (this._rowInsertedId) {
             this.model.disconnect(this._rowInsertedId);
             this._rowInsertedId = 0;
@@ -292,8 +294,6 @@ const WorldContentView = new Lang.Class({
             this.model.disconnect(this._rowDeletedId);
             this._rowDeletedId = 0;
         }
-
-        this.parent();
     },
 
     _updateEmpty: function() {


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