[polari] app: Disconnect window signals



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

    app: 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/application.js | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index dbb43f8a..37190dd1 100644
--- a/src/application.js
+++ b/src/application.js
@@ -427,13 +427,14 @@ export default GObject.registerClass({
             return;
 
         let action = this.lookup_action('leave-current-room');
-        window.connect('notify::active-room', () => {
-            action.enabled = window.active_room !== null;
-        });
         action.enabled = window.active_room !== null;
 
-        window.connect('active-room-state-changed',
-            this._updateUserListAction.bind(this));
+        this._toplevelSignals = [
+            window.connect('notify::active-room',
+                () => (action.enabled = window.active_room !== null)),
+            window.connect('active-room-state-changed',
+                () => this._updateUserListAction()),
+        ];
         this._updateUserListAction();
     }
 
@@ -442,6 +443,9 @@ export default GObject.registerClass({
             this.activate();
         else if (!this._settings.get_boolean('run-in-background'))
             this.emit('prepare-shutdown');
+
+        this._toplevelSignals.forEach(id => window.disconnect(id));
+        this._toplevelSignals = [];
     }
 
     vfunc_open(files) {


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