diff options
author | sr55 <[email protected]> | 2010-09-15 18:12:11 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2010-09-15 18:12:11 +0000 |
commit | 48b1861863208bea7b1dc36eb2f0773b5e09c045 (patch) | |
tree | 243fc09ceebaa1c259fe032525a9f5b5bc59b9a0 /win/C# | |
parent | b8353118c5cbd314514a6f9bcd2f566a0be0cd36 (diff) |
WinGui:
- Some changes to the way logging / exceptions are handled. This may fix an intermittent issue that causes a large number of exception windows to appear.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3533 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#')
-rw-r--r-- | win/C#/HandBrake.ApplicationServices/Services/Encode.cs | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/win/C#/HandBrake.ApplicationServices/Services/Encode.cs b/win/C#/HandBrake.ApplicationServices/Services/Encode.cs index a8cd3cadc..d922b66e6 100644 --- a/win/C#/HandBrake.ApplicationServices/Services/Encode.cs +++ b/win/C#/HandBrake.ApplicationServices/Services/Encode.cs @@ -23,7 +23,6 @@ namespace HandBrake.ApplicationServices.Services /// </summary>
public class Encode : IEncode
{
-
#region Private Variables
/// <summary>
@@ -123,7 +122,14 @@ namespace HandBrake.ApplicationServices.Services {
if (this.IsEncoding == false)
{
- ReadFile(); // Read the last log file back in if it exists
+ try
+ {
+ ReadFile(); // Read the last log file back in if it exists
+ }
+ catch (Exception exc)
+ {
+ return exc.ToString();
+ }
}
return string.IsNullOrEmpty(this.logBuffer.ToString()) ? "No log data available..." : this.logBuffer.ToString();
@@ -365,10 +371,6 @@ namespace HandBrake.ApplicationServices.Services try
{
- // Make sure the application readable log file does not already exist. FileCopy fill fail if it does.
- if (File.Exists(logFile2))
- File.Delete(logFile2);
-
// Copy the log file.
if (File.Exists(logFile))
File.Copy(logFile, logFile2, true);
@@ -377,24 +379,25 @@ namespace HandBrake.ApplicationServices.Services // Start the Reader
// Only use text which continues on from the last read line
- StreamReader sr = new StreamReader(logFile2);
- string line;
- int i = 1;
- while ((line = sr.ReadLine()) != null)
+ using (StreamReader sr = new StreamReader(logFile2))
{
- if (i > logFilePosition)
+ string line;
+ int i = 1;
+ while ((line = sr.ReadLine()) != null)
{
- logBuffer.AppendLine(line);
- logFilePosition++;
+ if (i > logFilePosition)
+ {
+ logBuffer.AppendLine(line);
+ logFilePosition++;
+ }
+ i++;
}
- i++;
+ sr.Close();
}
- sr.Close();
- sr.Dispose();
}
catch (Exception exc)
{
- errorService.ShowError("Unable to read log file", exc.ToString());
+ throw new Exception("Unable to read log file" + Environment.NewLine + exc);
}
}
}
@@ -428,6 +431,7 @@ namespace HandBrake.ApplicationServices.Services {
if (fileWriter != null)
fileWriter.Close();
+
errorService.ShowError("Error", exc.ToString());
}
}
@@ -455,7 +459,7 @@ namespace HandBrake.ApplicationServices.Services }
catch (Exception exc)
{
- errorService.ShowError("Unable to write log data...", exc.ToString());
+ // errorService.ShowError("Unable to write log data...", exc.ToString());
}
}
}
@@ -491,7 +495,7 @@ namespace HandBrake.ApplicationServices.Services }
catch (Exception exc)
{
- errorService.ShowError("An Unknown Error has occured", exc.ToString());
+ EncodeOnEncodeProgress(null, 0, 0, 0, 0, 0, "Unknown, status not available..");
}
}
|