[chronojump] Fixed strange crash on Linux "Too many open files" (seems mono does not close them)



commit 6c1662b5e78d5e2cc1cf3097eb0df1903df434be
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Jul 9 21:05:01 2014 +0200

    Fixed strange crash on Linux "Too many open files" (seems mono does not close them)

 src/constants.cs   |    2 ++
 src/gui/encoder.cs |    3 +--
 src/utilEncoder.cs |   11 ++++++++++-
 3 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/src/constants.cs b/src/constants.cs
index ea7e715..ccf8335 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -570,6 +570,8 @@ public class Constants
        
        public static string DatabaseNotFound = Catalog.GetString("Error. Cannot find database.");
        public static string DirectoryCannotOpen = Catalog.GetString("Error. Cannot open directory.");
+       public static string FileNotFound = Catalog.GetString("Error. File not found.");
+       public static string FileCopyProblem = Catalog.GetString("Error. Cannot copy file.");
 
        public static string ChronopicDefaultPortWindows = "COM?";
        public static string ChronopicDefaultPortLinux = "/dev/ttyUSB?";
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 4c238d1..a9a314b 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -1279,8 +1279,7 @@ public partial class ChronoJumpWindow
                        check_encoder_analyze_signal_or_curves.Active = true;
 
                        encoderButtonsSensitive(encoderSensEnumStored);
-               } else 
-                       new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("Sorry, file not 
found"));
+               }
        }
        
        protected void on_encoder_load_signal_row_edit (object o, EventArgs args) {
diff --git a/src/utilEncoder.cs b/src/utilEncoder.cs
index a42e41b..40365ff 100644
--- a/src/utilEncoder.cs
+++ b/src/utilEncoder.cs
@@ -143,9 +143,18 @@ public class UtilEncoder
                string origin = url + Path.DirectorySeparatorChar + fileName;
                string dest = GetEncoderDataTempFileName();
                if(File.Exists(origin)) {
-                       File.Copy(origin, dest, true);
+                       try {
+                               File.Copy(origin, dest, true);
+                       } catch {
+                               new DialogMessage(Constants.MessageTypes.WARNING, Constants.FileCopyProblem);
+                               Log.WriteLine(Constants.FileCopyProblem);
+                               return false;
+                       }
                        return true;
                }
+
+               new DialogMessage(Constants.MessageTypes.WARNING, Constants.FileNotFound);
+               Log.WriteLine(Constants.FileNotFound);
                return false;
        }
        


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