diff options
author | sr55 <[email protected]> | 2017-05-02 18:37:52 +0100 |
---|---|---|
committer | sr55 <[email protected]> | 2017-05-02 18:37:52 +0100 |
commit | e1bcb7af6947aed329924a82e58a45c143feedbf (patch) | |
tree | a7495b096666e6f3a0db35dcc75c6fbc5e4e9638 /win/CS/HandBrake.ApplicationServices/Interop | |
parent | b652292b6ae12e95f6ef24804a4cf8b51f32c47a (diff) |
WinGui: Improved logging around SCANDONE and some additional defensive programming to try track down this never ending scan.
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices/Interop')
-rw-r--r-- | win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs index 7114bab64..2c56a76c4 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs @@ -489,24 +489,40 @@ namespace HandBrake.ApplicationServices.Interop IntPtr json = HBFunctions.hb_get_state_json(this.hbHandle);
string statusJson = Marshal.PtrToStringAnsi(json);
this.log.LogMessage(statusJson, LogMessageType.Progress, LogLevel.Trace);
- JsonState state = JsonConvert.DeserializeObject<JsonState>(statusJson);
+ JsonState state = null;
+ if (!string.IsNullOrEmpty(statusJson))
+ {
+ state = JsonConvert.DeserializeObject<JsonState>(statusJson);
+ }
if (state != null && (state.State == NativeConstants.HB_STATE_SCANNING || state.State == NativeConstants.HB_STATE_SEARCHING))
{
- if (this.ScanProgress != null)
+ if (this.ScanProgress != null && state.Scanning != null)
{
this.ScanProgress(this, new ScanProgressEventArgs(state.Scanning.Progress, state.Scanning.Preview, state.Scanning.PreviewCount, state.Scanning.Title, state.Scanning.TitleCount));
}
}
else if (state != null && state.State == NativeConstants.HB_STATE_SCANDONE)
{
+ this.log.LogMessage("Scan: HB_STATE_SCANDONE", LogMessageType.API, LogLevel.Info);
+ this.scanPollTimer.Stop();
+
var jsonMsg = HBFunctions.hb_get_title_set_json(this.hbHandle);
string scanJson = InteropUtilities.ToStringFromUtf8Ptr(jsonMsg);
- this.log.LogMessage(scanJson, LogMessageType.Progress, LogLevel.Trace);
- this.titles = JsonConvert.DeserializeObject<JsonScanObject>(scanJson);
- this.featureTitle = this.titles.MainFeature;
+ this.log.LogMessage(scanJson, LogMessageType.Progress, LogLevel.Info);
- this.scanPollTimer.Stop();
+ if (string.IsNullOrEmpty(scanJson))
+ {
+ this.log.LogMessage("Scan Error: No Scan Data Returned.", LogMessageType.API, LogLevel.Error);
+ }
+ else
+ {
+ this.titles = JsonConvert.DeserializeObject<JsonScanObject>(scanJson);
+ if (this.titles != null)
+ {
+ this.featureTitle = this.titles.MainFeature;
+ }
+ }
if (this.ScanCompleted != null)
{
|