[gnome-shell/gnome-3-8] background: Disconnect settings signal handler on destroy



commit 331c73002f7ec52d3aa8bd8207513d775829207d
Author: Adel Gadllah <adel gadllah gmail com>
Date:   Wed Oct 2 15:29:30 2013 +0200

    background: Disconnect settings signal handler on destroy
    
    We connect to the changed signal in _init() but never actually disconnect from
    it. The callback has a reference to "this" which results into the background
    object not getting garbage collected.
    
    Fix that leaks by disconnecting in _destroy()
    
    https://bugzilla.gnome.org/show_bug.cgi?id=709263

 js/ui/background.js |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/js/ui/background.js b/js/ui/background.js
index 1d9ab7c..b855b4e 100644
--- a/js/ui/background.js
+++ b/js/ui/background.js
@@ -318,9 +318,9 @@ const Background = new Lang.Class({
         this._cancellable = new Gio.Cancellable();
         this.isLoaded = false;
 
-        this._settings.connect('changed', Lang.bind(this, function() {
-                                   this.emit('changed');
-                               }));
+        this._settingsChangedSignalId = this._settings.connect('changed', Lang.bind(this, function() {
+                                            this.emit('changed');
+                                        }));
 
         this._load();
     },
@@ -361,6 +361,10 @@ const Background = new Lang.Class({
 
         this.actor.disconnect(this._destroySignalId);
         this._destroySignalId = 0;
+
+        if (this._settingsChangedSignalId != 0)
+            this._settings.disconnect(this._settingsChangedSignalId);
+        this._settingsChangedSignalId = 0;
     },
 
     _setLoaded: function() {


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