summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrake.ApplicationServices
diff options
context:
space:
mode:
authorsr55 <[email protected]>2017-05-02 18:37:52 +0100
committersr55 <[email protected]>2017-05-02 18:37:52 +0100
commite1bcb7af6947aed329924a82e58a45c143feedbf (patch)
treea7495b096666e6f3a0db35dcc75c6fbc5e4e9638 /win/CS/HandBrake.ApplicationServices
parentb652292b6ae12e95f6ef24804a4cf8b51f32c47a (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')
-rw-r--r--win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs28
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Logging/LogService.cs2
2 files changed, 23 insertions, 7 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)
{
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Logging/LogService.cs b/win/CS/HandBrake.ApplicationServices/Services/Logging/LogService.cs
index ef869570a..abaf18e64 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Logging/LogService.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Logging/LogService.cs
@@ -103,7 +103,7 @@ namespace HandBrake.ApplicationServices.Services.Logging
return;
}
- if (level >= this.currentLogLevel)
+ if (level > this.currentLogLevel)
{
return;
}