[polari/wip/fmuellner/warning-fixes: 3/6] roomStack: Disconnect roomManager signals on destroy



commit bf7d23666fd4c7b8525bb13ad6eadaafd0e32e9a
Author: Florian Müllner <fmuellner gnome org>
Date:   Mon Dec 3 15:50:31 2018 +0100

    roomStack: Disconnect roomManager signals on destroy
    
    The room mananager is a singleton whose lifecycle is tied to the
    application, while any widget's lifecycle is tied to the window.
    App- and window lifecycle are different when Polari is set up to
    keep running in the background, so disconnect the signals to avoid
    warnings.
    
    https://gitlab.gnome.org/GNOME/polari/merge_requests/79

 src/roomStack.js | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/src/roomStack.js b/src/roomStack.js
index ff68be1..cccbaf9 100644
--- a/src/roomStack.js
+++ b/src/roomStack.js
@@ -24,8 +24,10 @@ var RoomStack = GObject.registerClass({
 
         this._roomManager = RoomManager.getDefault();
 
-        this._roomManager.connect('room-added', this._roomAdded.bind(this));
-        this._roomManager.connect('room-removed', this._roomRemoved.bind(this));
+        this._roomAddedId =
+            this._roomManager.connect('room-added', this._roomAdded.bind(this));
+        this._roomRemovedId =
+            this._roomManager.connect('room-removed', this._roomRemoved.bind(this));
         this._roomManager.rooms.forEach(r => { this._roomAdded(this._roomManager, r); });
 
         this.add_named(new ChatPlaceholder(this._sizeGroup), 'placeholder');
@@ -35,6 +37,11 @@ var RoomStack = GObject.registerClass({
             this._entryAreaHeight = rect.height - 1;
             this.notify('entry-area-height');
         });
+
+        this.connect('destroy', () => {
+            this._roomManager.disconnect(this._roomAddedId);
+            this._roomManager.disconnect(this._roomRemovedId);
+        });
     }
 
     vfunc_realize() {


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