[polari] roomStack: Disconnect window signals



commit f7348cacc9086f27f85d2cc3c3f3146377ef919f
Author: Florian Müllner <fmuellner gnome org>
Date:   Mon Jul 26 21:04:56 2021 +0200

    roomStack: Disconnect window signals
    
    So far we have just assumed that the toplevel window no longer
    emits any signals during destructions. We should properly clean
    up after ourselves instead.
    
    Part-of: <https://gitlab.gnome.org/GNOME/polari/-/merge_requests/230>

 src/roomStack.js | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/src/roomStack.js b/src/roomStack.js
index 5c150bc1..d6f5ce58 100644
--- a/src/roomStack.js
+++ b/src/roomStack.js
@@ -52,14 +52,24 @@ export default GObject.registerClass({
 
         const toplevel = this.get_root();
 
-        toplevel.connect('notify::active-room',
-            this._activeRoomChanged.bind(this));
-        toplevel.connect('active-room-state-changed',
-            this._updateSensitivity.bind(this));
+        this._toplevelSignals = [
+            toplevel.connect('notify::active-room',
+                this._activeRoomChanged.bind(this)),
+            toplevel.connect('active-room-state-changed',
+                this._updateSensitivity.bind(this)),
+        ];
         this._activeRoomChanged();
         this._updateSensitivity();
     }
 
+    vfunc_unrealize() {
+        super.vfunc_unrealize();
+
+        const toplevel = this.get_root();
+        this._toplevelSignals.forEach(id => toplevel.disconnect(id));
+        this._toplevelSignals = [];
+    }
+
     vfunc_size_allocate(allocation) {
         super.vfunc_size_allocate(allocation);
 


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