[gnome-chess] Fix critical warnings when starting a new game



commit 90a6f09a10238d75abf0541c15165b0f22ce85d6
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Tue Jan 7 20:24:37 2014 -0600

    Fix critical warnings when starting a new game
    
    Never try to remove the same source twice

 src/chess-engine.vala |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/src/chess-engine.vala b/src/chess-engine.vala
index 4791b29..536e73e 100644
--- a/src/chess-engine.vala
+++ b/src/chess-engine.vala
@@ -106,9 +106,11 @@ public abstract class ChessEngine : Object
 
     public void stop ()
     {
-        // FIXME sometimes this source does not exist...
         if (stdout_watch_id > 0)
+        {
             Source.remove (stdout_watch_id);
+            stdout_watch_id = 0;
+        }
 
         if (pid != 0)
             Posix.kill (pid, Posix.SIGTERM);
@@ -128,17 +130,20 @@ public abstract class ChessEngine : Object
         catch (ConvertError e)
         {
             warning ("Failed to read from engine: %s", e.message);
+            stdout_watch_id = 0;
             return false;
         }
         catch (IOChannelError e)
         {
             warning ("Failed to read from engine: %s", e.message);
+            stdout_watch_id = 0;
             return false;
         }
 
         if (status == IOStatus.EOF)
         {
             debug ("EOF");
+            stdout_watch_id = 0;
             return false;
         }
         if (status == IOStatus.NORMAL)


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