[gnome-weather/wip/ewlsh/gtk4] Handle window destroy correctly.



commit 3ef9d3fc03e3780aa7fcbe2192da101115d377eb
Author: Evan Welsh <contact evanwelsh com>
Date:   Tue Jan 5 15:30:43 2021 -0800

    Handle window destroy correctly.

 src/app/entry.js  | 1 +
 src/app/main.js   | 5 +++--
 src/app/window.js | 2 +-
 3 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/src/app/entry.js b/src/app/entry.js
index c6a45ac..7ae7ec7 100644
--- a/src/app/entry.js
+++ b/src/app/entry.js
@@ -354,6 +354,7 @@ var LocationSearchEntry = GObject.registerClass(
                 const text = source.get_text();
 
                 if (text === null || text === '') {
+                    this.cb?.(null);
                     this._filter?.set_search(null);
                     if (this._popup && this._popup.visible) {
                         this._popup.visible = false;
diff --git a/src/app/main.js b/src/app/main.js
index 83c23ba..00c61cf 100644
--- a/src/app/main.js
+++ b/src/app/main.js
@@ -188,7 +188,8 @@ const Application = GObject.registerClass(
     }
 
     _createWindow() {
-        return new Window.MainWindow({ application: this });
+        const window = new Window.MainWindow({ application: this });
+        return window;
     }
 
     _showWindowWhenReady(win) {
@@ -274,7 +275,7 @@ function main(argv) {
 
     application.connect("window-removed", (_, window) => {
         if (window instanceof Window.MainWindow) {
-            window._cleanup();
+            window.run_dispose();
         }
     });
 
diff --git a/src/app/window.js b/src/app/window.js
index 8ab2826..967fc94 100644
--- a/src/app/window.js
+++ b/src/app/window.js
@@ -122,7 +122,7 @@ var MainWindow = GObject.registerClass(
         this._showingDefault = false;
     }
 
-    _cleanup() {
+    on_destroy() {
         this._cityView._cleanup();
         this._searchEntry._cleanup();
     }


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