[gnome-shell/wip/fmuellner/gtk4: 10/20] extensions-app: Don't keep ref to main window




commit c2a91c7a47e45d37bf2a72fb50e40230c0d976c0
Author: Florian Müllner <fmuellner gnome org>
Date:   Wed Nov 18 02:16:26 2020 +0100

    extensions-app: Don't keep ref to main window
    
    Unlike in previous GTK version (or Clutter), destroy() no longer
    breaks reference cycles but just releases the reference held by
    GTK itself.
    
    So if we hold our own reference to the window, closing it won't be
    enough to be disposed, and the application won't quit.
    
    There is no good reason for the property anyway, just create the
    window on activate if necessary.

 subprojects/extensions-app/js/main.js | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/subprojects/extensions-app/js/main.js b/subprojects/extensions-app/js/main.js
index dc993ef966..21ae2bd878 100644
--- a/subprojects/extensions-app/js/main.js
+++ b/subprojects/extensions-app/js/main.js
@@ -50,7 +50,11 @@ class Application extends Gtk.Application {
 
     vfunc_activate() {
         this._shellProxy.CheckForUpdatesRemote();
-        this._window.present();
+
+        let { activeWindow } = this;
+        if (!activeWindow)
+            activeWindow = new ExtensionsWindow({ application: this });
+        activeWindow.present();
     }
 
     vfunc_startup() {
@@ -68,15 +72,13 @@ class Application extends Gtk.Application {
             Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
 
         const action = new Gio.SimpleAction({ name: 'quit' });
-        action.connect('activate', () => this._window.close());
+        action.connect('activate', () => this.active_window.close());
         this.add_action(action);
 
         this.set_accels_for_action('app.quit', ['<Primary>q']);
 
         this._shellProxy = new GnomeShellProxy(Gio.DBus.session,
             'org.gnome.Shell.Extensions', '/org/gnome/Shell/Extensions');
-
-        this._window = new ExtensionsWindow({ application: this });
     }
 });
 


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