[gnome-shell/wip/fmuellner/gtk4: 10/19] extensions-app: Clean up when window is unrealized




commit 3300a94b409154edb56d310226bcaa7a6bed061a
Author: Florian Müllner <fmuellner gnome org>
Date:   Wed Nov 18 02:13:40 2020 +0100

    extensions-app: Clean up when window is unrealized
    
    GTK4 no longer breaks any reference cycle when destroying a window,
    so we must release any reference we hold to not prevent the app
    from exiting.
    
    This involves all signal handlers that bind the window as `this`.

 subprojects/extensions-app/js/main.js | 36 ++++++++++++++++++++++++++++++-----
 1 file changed, 31 insertions(+), 5 deletions(-)
---
diff --git a/subprojects/extensions-app/js/main.js b/subprojects/extensions-app/js/main.js
index 21ae2bd878..a983beaef5 100644
--- a/subprojects/extensions-app/js/main.js
+++ b/subprojects/extensions-app/js/main.js
@@ -138,7 +138,7 @@ var ExtensionsWindow = GObject.registerClass({
             (w, event) => this._searchBar.handle_event(event));
 
         this._searchTerms = [];
-        this._searchEntry.connect('search-changed', () => {
+        this._searchId = this._searchEntry.connect('search-changed', () => {
             const { text } = this._searchEntry;
             if (text === '')
                 this._searchTerms = [];
@@ -173,16 +173,42 @@ var ExtensionsWindow = GObject.registerClass({
             visible: true,
         }));
 
-        this._shellProxy.connectSignal('ExtensionStateChanged',
-            this._onExtensionStateChanged.bind(this));
+        this._extensionStateChangedId =
+            this._shellProxy.connectSignal('ExtensionStateChanged',
+                this._onExtensionStateChanged.bind(this));
 
-        this._shellProxy.connect('g-properties-changed',
-            this._onUserExtensionsEnabledChanged.bind(this));
+        this._propertiesChangedId =
+            this._shellProxy.connect('g-properties-changed',
+                this._onUserExtensionsEnabledChanged.bind(this));
         this._onUserExtensionsEnabledChanged();
 
         this._scanExtensions();
     }
 
+    vfunc_unrealize() {
+        super.vfunc_unrealize();
+
+        this._exporter = null;
+
+        if (this._extensionStateChangedId)
+            this._shellProxy.disconnectSignal(this._extensionStateChangedId);
+        this._extensionStateChangedId = 0;
+
+        if (this._propertiesChangedId)
+            this._shellProxy.disconnect(this._propertiesChangedId);
+        this._propertiesChangedId = 0;
+
+        for (const actionName of this.list_actions())
+            this.remove_action(actionName);
+
+        this._userList.set_sort_func(null);
+        this._userList.set_filter_func(null);
+        this._systemList.set_sort_func(null);
+        this._systemList.set_filter_func(null);
+
+        this._searchEntry.disconnect(this._searchId);
+    }
+
     get _shellProxy() {
         return this.application.shellProxy;
     }


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