diff options
author | sr55 <[email protected]> | 2010-09-12 10:41:52 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2010-09-12 10:41:52 +0000 |
commit | c4e86a88047967c467dccfd48a6eda138956efdd (patch) | |
tree | caeed47edf3afd876941b0c0df74cde6db27b01d | |
parent | 87ca1ba95437d5164ac702480db675f62f2a38ea (diff) |
WinGui:
- Add some additional exception handling to allow debugging of random crashing in the activity window.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3518 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | win/C#/frmActivityWindow.cs | 89 |
1 files changed, 55 insertions, 34 deletions
diff --git a/win/C#/frmActivityWindow.cs b/win/C#/frmActivityWindow.cs index 598851f78..78c7927f4 100644 --- a/win/C#/frmActivityWindow.cs +++ b/win/C#/frmActivityWindow.cs @@ -13,6 +13,7 @@ namespace Handbrake using System.Threading;
using System.Windows.Forms;
+ using HandBrake.ApplicationServices.Services;
using HandBrake.ApplicationServices.Services.Interfaces;
using Model;
@@ -26,24 +27,29 @@ namespace Handbrake /* Private Variables */
/// <summary>
- /// The current position in the log file
+ /// The Encode Object
/// </summary>
- private int position;
+ private readonly IQueue encode;
/// <summary>
- /// A Timer for this window
+ /// The Scan Object
/// </summary>
- private Timer windowTimer;
+ private readonly IScan scan;
/// <summary>
- /// The Encode Object
+ /// The Error service
/// </summary>
- private IQueue encode;
+ private readonly IErrorService errorService = new ErrorService();
/// <summary>
- /// The Scan Object
+ /// The current position in the log file
+ /// </summary>
+ private int position;
+
+ /// <summary>
+ /// A Timer for this window
/// </summary>
- private IScan scan;
+ private Timer windowTimer;
/// <summary>
/// The Type of log that the window is currently dealing with
@@ -111,7 +117,7 @@ namespace Handbrake {
if (rtf_actLog.InvokeRequired)
{
- IAsyncResult invoked = BeginInvoke(new SetModeCallback(SetMode), new object[] {setMode});
+ IAsyncResult invoked = BeginInvoke(new SetModeCallback(SetMode), new object[] { setMode });
EndInvoke(invoked);
}
else
@@ -120,7 +126,7 @@ namespace Handbrake this.mode = setMode;
Array values = Enum.GetValues(typeof(ActivityLogMode));
- Properties.Settings.Default.ActivityWindowLastMode = (int) values.GetValue(Convert.ToInt32(setMode));
+ Properties.Settings.Default.ActivityWindowLastMode = (int)values.GetValue(Convert.ToInt32(setMode));
Properties.Settings.Default.Save();
this.Text = mode == ActivityLogMode.Scan
@@ -155,8 +161,15 @@ namespace Handbrake /// </param>
private void NewActivityWindow_Load(object sender, EventArgs e)
{
- ActivityLogMode activitLogMode = (ActivityLogMode) Enum.ToObject(typeof(ActivityLogMode), Properties.Settings.Default.ActivityWindowLastMode);
- SetMode(activitLogMode);
+ try
+ {
+ ActivityLogMode activitLogMode = (ActivityLogMode)Enum.ToObject(typeof(ActivityLogMode), Properties.Settings.Default.ActivityWindowLastMode);
+ SetMode(activitLogMode);
+ }
+ catch (Exception exc)
+ {
+ errorService.ShowError("Error during load.", exc.ToString());
+ }
}
/// <summary>
@@ -224,36 +237,44 @@ namespace Handbrake {
StringBuilder appendText = new StringBuilder();
- if (this.mode == ActivityLogMode.Scan)
+ try
{
- if (scan == null || scan.ActivityLog == string.Empty)
+ if (this.mode == ActivityLogMode.Scan)
{
- appendText.AppendFormat("Waiting for the log to be generated ...\n");
- position = 0;
- ClearWindowText();
- return appendText;
- }
+ if (scan == null || scan.ActivityLog == string.Empty)
+ {
+ appendText.AppendFormat("Waiting for the log to be generated ...\n");
+ position = 0;
+ ClearWindowText();
+ return appendText;
+ }
- using (StringReader reader = new StringReader(scan.ActivityLog))
- {
- LogReader(reader, appendText);
+ using (StringReader reader = new StringReader(scan.ActivityLog))
+ {
+ LogReader(reader, appendText);
+ }
}
- }
- else
- {
- if (encode == null || encode.ActivityLog == string.Empty)
+ else
{
- appendText.AppendFormat("Waiting for the log to be generated ...\n");
- position = 0;
- ClearWindowText();
- return appendText;
- }
+ if (encode == null || encode.ActivityLog == string.Empty)
+ {
+ appendText.AppendFormat("Waiting for the log to be generated ...\n");
+ position = 0;
+ ClearWindowText();
+ return appendText;
+ }
- using (StringReader reader = new StringReader(encode.ActivityLog))
- {
- LogReader(reader, appendText);
+ using (StringReader reader = new StringReader(encode.ActivityLog))
+ {
+ LogReader(reader, appendText);
+ }
}
}
+ catch (Exception exc)
+ {
+ errorService.ShowError("GetLog() Error", exc.ToString());
+ }
+
return appendText;
}
|