[gnome-chess] Don't declare error immediately after engine quits



commit 749c36dc101c5dffc96fb8a255c15335ac78c04e
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Sun Oct 13 14:07:19 2013 -0500

    Don't declare error immediately after engine quits
    
    Chill out a moment or two. Don't lose the race between the ChildWatch
    and the IOWatch.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=710028

 src/gnome-chess.vala |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index da61e63..a88d862 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -673,7 +673,18 @@ public class Application : Gtk.Application
 
     private void engine_stopped_cb (ChessEngine engine)
     {
-        game.stop (ChessResult.BUG, ChessRule.BUG);
+        /*
+         * Many engines close themselves immediately after the end of the game.
+         * So wait two seconds before displaying the unfortunate result. The
+         * game is likely to end naturally first. (And in the off chance that
+         * the game really is over but it takes more than two seconds for us to
+         * figure that out, something really HAS gone wrong.)
+         */
+        Timeout.add_seconds (2, () => {
+            game.stop (ChessResult.BUG, ChessRule.BUG);
+            /* Disconnect from the mainloop */
+            return false;
+        });
     }
 
     private void engine_error_cb (ChessEngine engine)


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