[swell-foop/arnaudb/event-controller-motion: 3/4] Fix Scores dialog showing on Alt-F4.



commit 0574d05d8d17a2322fd4c99e2a9f88e82e3e62c2
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Mon May 4 20:22:33 2020 +0200

    Fix Scores dialog showing on Alt-F4.

 src/swell-foop.vala |  2 +-
 src/window.vala     | 10 +++++++---
 2 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/src/swell-foop.vala b/src/swell-foop.vala
index f45610a..39c8c3f 100644
--- a/src/swell-foop.vala
+++ b/src/swell-foop.vala
@@ -71,7 +71,7 @@ public class SwellFoop : Gtk.Application
 
     protected override void shutdown ()
     {
-        window.on_shutdown ();
+        window.destroy ();
         base.shutdown ();
     }
 
diff --git a/src/window.vala b/src/window.vala
index f68cf0c..9a5c8e8 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -204,11 +204,14 @@ private class SwellFoopWindow : ApplicationWindow
         view.is_zealous = is_zealous;
     }
 
-    internal inline void on_shutdown ()
+    private bool being_destroyed = false;
+    protected override void destroy ()
     {
         /* Record the score if the game isn't over. */
+        being_destroyed = true;
         if (game != null && !game.has_completed () && game.score > 0)
-            complete_cb ();
+            add_score ();
+        base.destroy ();
     }
 
     /*\
@@ -423,7 +426,8 @@ private class SwellFoopWindow : ApplicationWindow
                 {
                     warning ("Failed to add score: %s", e.message);
                 }
-                scores_context.run_dialog ();
+                if (!being_destroyed)
+                    scores_context.run_dialog ();
             });
     }
 }


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