]> granicus.if.org Git - handbrake/commitdiff
WinGui: Cancel Scan will now close the status panel if the scan cancellation fails...
authorsr55 <sr55.hb@outlook.com>
Tue, 11 Apr 2017 13:24:38 +0000 (14:24 +0100)
committersr55 <sr55.hb@outlook.com>
Tue, 11 Apr 2017 13:24:38 +0000 (14:24 +0100)
win/CS/HandBrakeWPF/Services/Scan/LibScan.cs
win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs

index 7be5db8f01808331029adad2b9684a44b6e65053..fdeb88b2d9401902545d5cb93bb9f0ee811185ea 100644 (file)
@@ -25,7 +25,6 @@ namespace HandBrakeWPF.Services.Scan
     using HandBrake.ApplicationServices.Services.Logging.Interfaces;
     using HandBrake.ApplicationServices.Services.Logging.Model;
 
-    using HandBrakeWPF.Properties;
     using HandBrakeWPF.Services.Encode.Model;
     using HandBrakeWPF.Services.Encode.Model.Models;
     using HandBrakeWPF.Services.Scan.EventArgs;
@@ -122,6 +121,8 @@ namespace HandBrakeWPF.Services.Scan
                 }
             }
 
+            this.isCancelled = false;
+
             // Handle the post scan operation.
             this.postScanOperation = postAction;
 
@@ -141,15 +142,18 @@ namespace HandBrakeWPF.Services.Scan
         {
             try
             {
-                this.ServiceLogMessage("Stopping Scan.");
+                this.ServiceLogMessage("Stopping Scan ...");
                 this.IsScanning = false;
                 this.instance.StopScan();
+                this.ServiceLogMessage("Scan Stopped ...");
             }
             catch (Exception exc)
             {
-                this.isCancelled = false;
-                this.ScanCompleted?.Invoke(this, new ScanCompletedEventArgs(false, exc, Resources.ScanService_ScanStopFailed, null));
-                // Do Nothing.
+                this.ServiceLogMessage(exc.ToString());
+            }
+            finally
+            {
+                this.ScanCompleted?.Invoke(this, new ScanCompletedEventArgs(this.isCancelled, null, null, null));
             }
         }
 
@@ -206,7 +210,7 @@ namespace HandBrakeWPF.Services.Scan
             }
             catch (AccessViolationException e)
             {
-                Console.WriteLine(e);
+                Debug.WriteLine(e);
             }
 
             return bitmapImage;
@@ -266,8 +270,6 @@ namespace HandBrakeWPF.Services.Scan
             {
                 this.ServiceLogMessage("Scan Failed ..." + Environment.NewLine + exc);
                 this.Stop();
-
-                this.ScanCompleted?.Invoke(this, new ScanCompletedEventArgs(false, exc, "An Error has occured in ScanService.ScanSource()", null));
             }
         }
 
@@ -286,7 +288,7 @@ namespace HandBrakeWPF.Services.Scan
         /// </param>
         private void InstanceScanCompleted(object sender, System.EventArgs e)
         {
-            this.ServiceLogMessage("Scan Finished ...");
+            this.ServiceLogMessage("Processing Scan Information ...");
             bool cancelled = this.isCancelled;
             this.isCancelled = false;
 
@@ -318,10 +320,12 @@ namespace HandBrakeWPF.Services.Scan
                 }
 
                 this.postScanOperation = null; // Reset
+                this.ServiceLogMessage("Scan Finished for Queue Edit ...");
             }
             else
             {
                 this.ScanCompleted?.Invoke(this, new ScanCompletedEventArgs(cancelled, null, string.Empty, sourceData));
+                this.ServiceLogMessage("Scan Finished ...");
             }
         }
 
index f29e6fac05a0585efda1ee63df3d1b472de3f009..283111b1167c86b72276f5671312fac0ce057f57 100644 (file)
@@ -1619,6 +1619,7 @@ namespace HandBrakeWPF.ViewModels
         /// </summary>\r
         public void CancelScan()\r
         {\r
+            this.ShowStatusWindow = false;\r
             this.scanService.Cancel();\r
         }\r
 \r
@@ -2346,6 +2347,8 @@ namespace HandBrakeWPF.ViewModels
 \r
             Execute.OnUIThread(() =>\r
             {\r
+                this.ShowStatusWindow = false;\r
+\r
                 if (e.Successful)\r
                 {\r
                     this.NotifyOfPropertyChange(() => this.ScannedSource);\r
@@ -2358,7 +2361,6 @@ namespace HandBrakeWPF.ViewModels
                     this.OpenAlertWindow(Resources.Main_ScanNoTitlesFound, Resources.Main_ScanNoTitlesFoundMessage);\r
                 }\r
 \r
-                this.ShowStatusWindow = false;\r
                 if (e.Successful)\r
                 {\r
                     this.SourceLabel = this.SourceName;\r