From 49678e0ac3919a53319705ea19a41187d5b0bc35 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sun, 12 Sep 2010 10:41:52 +0000 Subject: [PATCH] WinGui: - Add some additional exception handling to allow debugging of random crashing in the activity window. git-svn-id: svn://localhost/HandBrake/trunk@3518 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/C#/frmActivityWindow.cs | 89 ++++++++++++++++++++++++++++----------------- 1 file changed, 55 insertions(+), 34 deletions(-) diff --git a/win/C#/frmActivityWindow.cs b/win/C#/frmActivityWindow.cs index 598851f7..78c7927f 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 */ /// - /// The current position in the log file + /// The Encode Object /// - private int position; + private readonly IQueue encode; /// - /// A Timer for this window + /// The Scan Object /// - private Timer windowTimer; + private readonly IScan scan; /// - /// The Encode Object + /// The Error service /// - private IQueue encode; + private readonly IErrorService errorService = new ErrorService(); /// - /// The Scan Object + /// The current position in the log file + /// + private int position; + + /// + /// A Timer for this window /// - private IScan scan; + private Timer windowTimer; /// /// 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 /// 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()); + } } /// @@ -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; } -- 2.11.0