[polari] roomList: Disconnect from account signals on destroy



commit 342f5ee319e6a5172be73e4cb22dd79a6bee2868
Author: Bastian Ilsø <bastianilso src gnome org>
Date:   Tue Sep 1 23:26:55 2015 +0200

    roomList: Disconnect from account signals on destroy
    
    The lifetime of the account may be longer than the
    lifetime of the header, so disconnect from the signals
    again when destroyed.

 src/roomList.js |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/src/roomList.js b/src/roomList.js
index 3feb244..2ed7e75 100644
--- a/src/roomList.js
+++ b/src/roomList.js
@@ -165,13 +165,20 @@ const RoomListHeader = new Lang.Class({
                 this._errorPopover.hide();
             }));
 
-        this._account.connect('notify::display-name',
-                              Lang.bind(this, this._onDisplayNameChanged));
+        let displayNameChangedId =
+            this._account.connect('notify::display-name',
+                                  Lang.bind(this, this._onDisplayNameChanged));
         this._onDisplayNameChanged();
 
-        this._account.connect('notify::connection-status',
-                              Lang.bind(this, this._updateConnectionStatusIcon));
+        let connectionStatusChangedId =
+            this._account.connect('notify::connection-status',
+                                  Lang.bind(this, this._updateConnectionStatusIcon));
         this._updateConnectionStatusIcon();
+
+        this.connect('destroy', Lang.bind(this, function() {
+            this._account.disconnect(displaynameChangedId);
+            this._account.disconnect(connectionstatusChangedId);
+        }));
     },
 
     _onDisplayNameChanged: function() {


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