summaryrefslogtreecommitdiffstats
path: root/win/C#/HandBrake.Framework
diff options
context:
space:
mode:
authorsr55 <[email protected]>2010-09-26 16:10:16 +0000
committersr55 <[email protected]>2010-09-26 16:10:16 +0000
commit944fe868810ac0438ae97b1ade8c7cff2de05192 (patch)
tree886d04c858ea026d938b83c8b6fe0ba1e5af262d /win/C#/HandBrake.Framework
parent1bca5338bb277f7351c67c890fc8fbc6b4fdbc71 (diff)
WinGui:
- The scan log will no longer be written to disk if the log is over 100MB. An error message will be thrown. - The encode will be terminated if the log file grows beyond 100MB and an error message will be thrown. - Fixed an issue with the exception window not appearing when called from a worker thead. - Put a limit on the number of exception windows that can appear during a session of HandBrake. (set to 30) git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3554 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#/HandBrake.Framework')
-rw-r--r--win/C#/HandBrake.Framework/Services/ErrorService.cs26
1 files changed, 23 insertions, 3 deletions
diff --git a/win/C#/HandBrake.Framework/Services/ErrorService.cs b/win/C#/HandBrake.Framework/Services/ErrorService.cs
index 5444ea7bc..41372648d 100644
--- a/win/C#/HandBrake.Framework/Services/ErrorService.cs
+++ b/win/C#/HandBrake.Framework/Services/ErrorService.cs
@@ -8,6 +8,7 @@ namespace HandBrake.Framework.Services
using System;
using System.IO;
using System.Threading;
+ using System.Windows.Forms;
using HandBrake.Framework.Services.Interfaces;
using HandBrake.Framework.Views;
@@ -17,6 +18,8 @@ namespace HandBrake.Framework.Services
/// </summary>
public class ErrorService : IErrorService
{
+ private int exceptionCount;
+
/// <summary>
/// Show an Error Window
/// </summary>
@@ -28,6 +31,8 @@ namespace HandBrake.Framework.Services
/// </param>
public void ShowError(string shortError, string longError)
{
+ exceptionCount++;
+
try
{
Thread newThread = new Thread(new ParameterizedThreadStart(WriteExceptionToFile));
@@ -38,9 +43,19 @@ namespace HandBrake.Framework.Services
// Do Nothing
}
+ if (exceptionCount > 30)
+ {
+ // If we are getting a large number of exceptions, just die out. We don't want to fill the users drive with a ton
+ // of exception files.
+ return;
+ }
+
ExceptionWindow window = new ExceptionWindow();
window.Setup(shortError, longError);
- window.Show();
+
+ // This seems far from ideal so maybe have a think about a better way of doing this.
+ // This method can be called from UI and worker threads, so the ExcWindow needs to be called on the UI thread or on it's on UI thread.
+ Application.Run(window);
}
/// <summary>
@@ -67,6 +82,13 @@ namespace HandBrake.Framework.Services
{
try
{
+ if (exceptionCount > 30)
+ {
+ // If we are getting a large number of exceptions, just die out. We don't want to fill the users drive with a ton
+ // of exception files.
+ return;
+ }
+
string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";
string file = Path.Combine(logDir, string.Format("Exception_{0}.txt", DateTime.Now.Ticks));
@@ -75,8 +97,6 @@ namespace HandBrake.Framework.Services
using (StreamWriter streamWriter = new StreamWriter(file))
{
streamWriter.WriteLine(state.ToString());
- streamWriter.Close();
- streamWriter.Dispose();
}
}
}