diff options
author | sr55 <[email protected]> | 2015-02-07 17:01:36 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2015-02-07 17:01:36 +0000 |
commit | cd089d45e8b6a7f60699f493ee250707b1485007 (patch) | |
tree | a849b86e15f6677386d6a6e88ee33ed9cc20cd77 /win/CS/HandBrake.Interop | |
parent | 753beb7d5c3b4de3d237d9e43b00e3e237bc8b36 (diff) |
WinGui: Some improvements to Exception Handling, Debug information etc in the new LibHB code.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6879 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.Interop')
-rw-r--r-- | win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs index 6920295cb..906781835 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs @@ -207,7 +207,14 @@ namespace HandBrake.Interop // Lambda notation used to make sure we can view any JIT exceptions the method throws
this.scanPollTimer.Elapsed += (o, e) =>
{
- this.PollScanProgress();
+ try
+ {
+ this.PollScanProgress();
+ }
+ catch (Exception exc)
+ {
+ Debug.WriteLine(exc);
+ }
};
this.scanPollTimer.Start();
}
@@ -215,6 +222,7 @@ namespace HandBrake.Interop /// <summary>
/// Stops an ongoing scan.
/// </summary>
+ [HandleProcessCorruptedStateExceptions]
public void StopScan()
{
HBFunctions.hb_scan_stop(this.hbHandle);
@@ -357,7 +365,14 @@ namespace HandBrake.Interop this.encodePollTimer.Elapsed += (o, e) =>
{
- this.PollEncodeProgress();
+ try
+ {
+ this.PollEncodeProgress();
+ }
+ catch (Exception exc)
+ {
+ Debug.WriteLine(exc);
+ }
};
this.encodePollTimer.Start();
}
@@ -442,13 +457,14 @@ namespace HandBrake.Interop /// <summary>
/// Checks the status of the ongoing scan.
/// </summary>
+ [HandleProcessCorruptedStateExceptions]
private void PollScanProgress()
{
IntPtr json = HBFunctions.hb_get_state_json(this.hbHandle);
string statusJson = Marshal.PtrToStringAnsi(json);
JsonState state = JsonConvert.DeserializeObject<JsonState>(statusJson);
- if (state.State == NativeConstants.HB_STATE_SCANNING)
+ if (state != null && state.State == NativeConstants.HB_STATE_SCANNING)
{
if (this.ScanProgress != null)
{
@@ -462,7 +478,7 @@ namespace HandBrake.Interop });
}
}
- else if (state.State == NativeConstants.HB_STATE_SCANDONE)
+ else if (state != null && state.State == NativeConstants.HB_STATE_SCANDONE)
{
this.titles = new List<Title>();
@@ -495,13 +511,14 @@ namespace HandBrake.Interop /// <summary>
/// Checks the status of the ongoing encode.
/// </summary>
+ [HandleProcessCorruptedStateExceptions]
private void PollEncodeProgress()
{
IntPtr json = HBFunctions.hb_get_state_json(this.hbHandle);
string statusJson = Marshal.PtrToStringAnsi(json);
JsonState state = JsonConvert.DeserializeObject<JsonState>(statusJson);
- if (state.State == NativeConstants.HB_STATE_WORKING)
+ if (state != null && state.State == NativeConstants.HB_STATE_WORKING)
{
if (this.EncodeProgress != null)
{
@@ -517,7 +534,7 @@ namespace HandBrake.Interop this.EncodeProgress(this, progressEventArgs);
}
}
- else if (state.State == NativeConstants.HB_STATE_WORKDONE)
+ else if (state != null && state.State == NativeConstants.HB_STATE_WORKDONE)
{
this.encodePollTimer.Stop();
|