[polari/wip/fmuellner/invalid-object-access: 10/10] serverRoomList: Disconnect ::loading-changed signal on destroy



commit d48ed94feba66741a5d57cb6598bcc837126e994
Author: Florian Müllner <fmuellner gnome org>
Date:   Sat Dec 9 22:21:12 2017 +0100

    serverRoomList: Disconnect ::loading-changed signal on destroy
    
    The ServerRoomManager is a singleton that exists for the life time
    of the application, so we need to disconnect any signals when the
    widget is destroyed.
    
    https://gitlab.gnome.org/GNOME/polari/issues/32

 src/serverRoomManager.js | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/src/serverRoomManager.js b/src/serverRoomManager.js
index c0d7656..6c25179 100644
--- a/src/serverRoomManager.js
+++ b/src/serverRoomManager.js
@@ -130,10 +130,6 @@ var ServerRoomList = GObject.registerClass({
 
         super._init(params);
 
-        this.connect('destroy', () => {
-            this.setAccount(null);
-        });
-
         this._list.model.set_visible_func((model, iter) => {
             let name = model.get_value(iter, RoomListColumn.NAME);
             if (!name)
@@ -186,8 +182,15 @@ var ServerRoomList = GObject.registerClass({
         });
 
         this._manager = ServerRoomManager.getDefault();
-        this._manager.connect('loading-changed',
-                              this._onLoadingChanged.bind(this));
+        let loadingChangedId =
+            this._manager.connect('loading-changed',
+                                  this._onLoadingChanged.bind(this));
+
+        this.connect('destroy', () => {
+            this.setAccount(null);
+
+            this._manager.disconnect(loadingChangedId);
+        });
     }
 
     get can_join() {


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