[gnome-chess] chess_game_remove_hold: assertion '_tmp0_ > 0' failed



commit 295c0a36506762774b82936bfeac2fa164d730c4
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Sat Nov 2 15:06:59 2013 -0500

    chess_game_remove_hold: assertion '_tmp0_ > 0' failed
    
    This occurred when starting a new game. We would call remove_hold on the
    new ChessGame object as a consequence of "finishing" the animation for
    the previous game. But no hold had ever been placed on the new object.

 src/chess-scene.vala |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/src/chess-scene.vala b/src/chess-scene.vala
index 5b635e6..882b009 100644
--- a/src/chess-scene.vala
+++ b/src/chess-scene.vala
@@ -82,12 +82,20 @@ public class ChessScene : Object
     public int selected_rank = -1;
     public int selected_file = -1;
 
+    private uint animate_timeout_id = 0;
+
     private ChessGame? _game = null;
     public ChessGame? game
     {
         get { return _game; }
         set
         {
+            if (animate_timeout_id != 0)
+            {
+                Source.remove (animate_timeout_id);
+                animate_timeout_id = 0;
+                animating = false;
+            }
             _game = value;
             _move_number = -1;
             selected_rank = -1;
@@ -325,7 +333,7 @@ public class ChessScene : Object
             game.add_hold ();
 
             /* Animate every 10ms (up to 100fps) */
-            Timeout.add (10, animate_cb, Priority.DEFAULT_IDLE);
+            animate_timeout_id = Timeout.add (10, animate_cb, Priority.DEFAULT_IDLE);
         }
     }
 


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