[chronojump] Don't crash if encoder cable disconn. when reading



commit 55099bb87ce60fd12c0484bd56fc42546908bb52
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed May 7 21:42:32 2014 +0200

    Don't crash if encoder cable disconn. when reading

 src/gui/encoder.cs |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 5166b5d..b088431 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -1911,7 +1911,14 @@ public partial class ChronoJumpWindow
 
 
                do {
-                       byteReadedRaw = sp.ReadByte();
+                       try {
+                               byteReadedRaw = sp.ReadByte();
+                       } catch {
+                               Log.WriteLine("Maybe encoder cable is disconnected");
+                               encoderProcessCancel = true;
+                               break;
+                       }
+
                        if(byteReadedRaw > 128)
                                byteReadedRaw = byteReadedRaw - 256;
 


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