[gnome-sudoku] Fix Undo/Redo after using Clear Board



commit e9220efac46154b824789a32f6f62f800d499ec5
Author: Parin Porecha <parinporecha gmail com>
Date:   Thu Jun 12 20:41:12 2014 +0530

    Fix Undo/Redo after using Clear Board
    
    https://bugzilla.gnome.org/show_bug.cgi?id=731216

 src/gnome-sudoku.vala |    4 ++++
 src/sudoku-game.vala  |    7 +++----
 2 files changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/src/gnome-sudoku.vala b/src/gnome-sudoku.vala
index d7bcc6c..ef9cbd6 100644
--- a/src/gnome-sudoku.vala
+++ b/src/gnome-sudoku.vala
@@ -354,7 +354,11 @@ public class Sudoku : Gtk.Application
 
         dialog.response.connect ((response_id) => {
             if (response_id == ResponseType.OK)
+            {
                 game.reset ();
+                undo_action.set_enabled (false);
+                redo_action.set_enabled (false);
+            }
             dialog.destroy ();
         });
 
diff --git a/src/sudoku-game.vala b/src/sudoku-game.vala
index 31fc560..4fcb161 100644
--- a/src/sudoku-game.vala
+++ b/src/sudoku-game.vala
@@ -66,17 +66,16 @@ public class SudokuGame
     public void reset ()
     {
         timer.reset();
-        var count = board.filled;
+        undostack = null;
+        redostack = null;
         for (var l1 = 0; l1 < board.rows; l1++)
         {
             for (var l2 = 0; l2 < board.cols; l2++)
             {
                 if (!board.is_fixed[l1, l2])
-                    remove (l1, l2);
+                    board.remove (l1, l2);
             }
         }
-        count -= board.filled;
-        add_to_stack (ref undostack, -1, -1, count);
     }
 
     public void cell_changed_cb (int row, int col, int old_val, int new_val)


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