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 | |
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')
3 files changed, 24 insertions, 8 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; } diff --git a/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs b/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs index eac84f263..955e769ed 100644 --- a/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs +++ b/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs @@ -142,7 +142,7 @@ namespace HandBrakeWPF.Services.Scan { try { - this.ServiceLogMessage("Stopping Scan ..."); + this.ServiceLogMessage("Manually Stopping Scan ..."); this.IsScanning = false; this.instance.StopScan(); } |