[gnome-sudoku] Games when closed with empty board redirects to new game screen on the next run.



commit 14f2e6c30ad004d431f26c18601c631de3140592
Author: amishas157 <amishas157 gmail com>
Date:   Fri Sep 5 17:21:01 2014 +0530

    Games when closed with empty board redirects to new game screen on the next run.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=735818

 src/gnome-sudoku.vala |   25 +++++++++++++++++++++----
 1 files changed, 21 insertions(+), 4 deletions(-)
---
diff --git a/src/gnome-sudoku.vala b/src/gnome-sudoku.vala
index 4d19294..5afcd16 100644
--- a/src/gnome-sudoku.vala
+++ b/src/gnome-sudoku.vala
@@ -162,15 +162,32 @@ public class Sudoku : Gtk.Application
 
     protected override void shutdown ()
     {
-        if (game != null && !game.board.is_empty () && !game.board.complete)
-            saver.save_game (game);
+        if (game != null)
+        {
+            if (!game.board.is_empty () && !game.board.complete)
+                saver.save_game (game);
 
-        base.shutdown ();
+            if (game.board.is_empty () && saver.get_savedgame () != null)
+            {
+                var file = File.new_for_path (SudokuSaver.savegame_file);
+
+                try
+                {
+                    file.delete ();
+                }
+                catch (Error e)
+                {
+                    warning ("Failed to delete saved game: %s", e.message);
+                }
+            }
+        }
 
         /* Save window state */
         settings.set_int ("window-width", window_width);
         settings.set_int ("window-height", window_height);
         settings.set_boolean ("window-is-maximized", is_maximized);
+
+        base.shutdown ();
     }
 
     private bool window_configure_event_cb (Gdk.EventConfigure event)


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