WinGui: Handle the Logging events a bit better. This will stop some of the cross...
authorsr55 <sr55.hb@outlook.com>
Sat, 24 Jan 2015 16:27:24 +0000 (16:27 +0000)
committersr55 <sr55.hb@outlook.com>
Sat, 24 Jan 2015 16:27:24 +0000 (16:27 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6809 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs
win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs

index 0ed17fb5105f81ffe8e15b6eb267b91872b28138..942644f2ee8cb49155d8c494b67ffe651433e14b 100644 (file)
@@ -62,8 +62,6 @@ namespace HandBrake.ApplicationServices.Services.Encode
         /// </summary>\r
         public LibEncode()\r
         {\r
-            HandBrakeUtils.MessageLogged += this.HandBrakeInstanceMessageLogged;\r
-            HandBrakeUtils.ErrorLogged += this.HandBrakeInstanceErrorLogged;\r
         }\r
 \r
         /// <summary>\r
@@ -96,6 +94,8 @@ namespace HandBrake.ApplicationServices.Services.Encode
 \r
             // Create a new HandBrake instance\r
             // Setup the HandBrake Instance\r
+            HandBrakeUtils.MessageLogged += this.HandBrakeInstanceMessageLogged;\r
+            HandBrakeUtils.ErrorLogged += this.HandBrakeInstanceErrorLogged;\r
             this.instance = HandBrakeInstanceManager.GetEncodeInstance(job.Configuration.Verbosity);\r
             this.instance.EncodeCompleted += this.InstanceEncodeCompleted;\r
             this.instance.EncodeProgress += this.InstanceEncodeProgress;\r
@@ -348,6 +348,9 @@ namespace HandBrake.ApplicationServices.Services.Encode
                     ? new EventArgs.EncodeCompletedEventArgs(false, null, string.Empty, this.currentTask.Task.Destination)\r
                     : new EventArgs.EncodeCompletedEventArgs(true, null, string.Empty, this.currentTask.Task.Destination));\r
 \r
+            HandBrakeUtils.MessageLogged -= this.HandBrakeInstanceMessageLogged;\r
+            HandBrakeUtils.ErrorLogged -= this.HandBrakeInstanceErrorLogged;\r
+\r
             this.ShutdownFileWriter();\r
         }\r
         #endregion\r
index 796ef5db506528866d1da9455e5f833b74118dfe..721959a90bbb6103dae59e3ef962957e5a1c62e0 100644 (file)
@@ -101,18 +101,7 @@ namespace HandBrake.ApplicationServices.Services.Scan
         public LibScan()\r
         {\r
             this.logging = new StringBuilder();\r
-\r
             this.header = GeneralUtilities.CreateCliLogHeader();\r
-\r
-            try\r
-            {\r
-                HandBrakeUtils.MessageLogged += this.HandBrakeInstanceMessageLogged;\r
-                HandBrakeUtils.ErrorLogged += this.HandBrakeInstanceErrorLogged;\r
-            }\r
-            catch (Exception)\r
-            {\r
-                // Do nothing. \r
-            }\r
         }\r
 \r
         #region Events\r
@@ -226,6 +215,8 @@ namespace HandBrake.ApplicationServices.Services.Scan
             this.scanLog = new StreamWriter(this.dvdInfoPath);\r
 \r
             // Create a new HandBrake Instance.\r
+            HandBrakeUtils.MessageLogged += this.HandBrakeInstanceMessageLogged;\r
+            HandBrakeUtils.ErrorLogged += this.HandBrakeInstanceErrorLogged;\r
             this.instance = HandBrakeInstanceManager.GetScanInstance(configuraiton.Verbosity);\r
             this.instance.ScanProgress += this.InstanceScanProgress;\r
             this.instance.ScanCompleted += this.InstanceScanCompleted;\r
@@ -374,6 +365,9 @@ namespace HandBrake.ApplicationServices.Services.Scan
                 // Do Nothing.\r
             }\r
 \r
+            HandBrakeUtils.MessageLogged -= this.HandBrakeInstanceMessageLogged;\r
+            HandBrakeUtils.ErrorLogged -= this.HandBrakeInstanceErrorLogged;\r
+\r
             // TODO -> Might be a better place to fix this.\r
             string path = this.currentSourceScanPath;\r
             if (this.currentSourceScanPath.Contains("\""))\r