diff options
author | sr55 <[email protected]> | 2019-02-03 22:15:53 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2019-02-03 22:15:53 +0000 |
commit | 948a6712a11a7fe1f1f314ebb26f728a00ba963c (patch) | |
tree | 62035edd398586d9475259d504a12a6ff951ed4d /win/CS/HandBrakeWPF | |
parent | 677823cf7c23b52c456c4e8e4a4501688e6398dd (diff) |
WinGui: Fix instance handling in Libencode.
Diffstat (limited to 'win/CS/HandBrakeWPF')
-rw-r--r-- | win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs b/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs index ca4100b62..3b9e01280 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs @@ -78,6 +78,23 @@ namespace HandBrakeWPF.Services.Encode // Create a new HandBrake instance // Setup the HandBrake Instance this.log.Reset(); // Reset so we have a clean log for the start of the encode. + + if (this.instance != null) + { + // Cleanup + try + { + this.instance.EncodeCompleted -= this.InstanceEncodeCompleted; + this.instance.EncodeProgress -= this.InstanceEncodeProgress; + this.instance.Dispose(); + this.instance = null; + } + catch (Exception exc) + { + this.ServiceLogMessage("Failed to cleanup previous instance: " + exc); + } + } + this.ServiceLogMessage("Starting Encode ..."); this.instance = task.IsPreviewEncode ? HandBrakeInstanceManager.GetPreviewInstance(configuration.Verbosity, configuration) : HandBrakeInstanceManager.GetEncodeInstance(configuration.Verbosity, configuration); @@ -143,10 +160,6 @@ namespace HandBrakeWPF.Services.Encode if (this.instance != null) { this.instance.StopEncode(); - this.instance.EncodeCompleted -= this.InstanceEncodeCompleted; - this.instance.EncodeProgress -= this.InstanceEncodeProgress; - this.instance.Dispose(); - this.instance = null; this.ServiceLogMessage("Encode Stopped"); } } @@ -218,19 +231,6 @@ namespace HandBrakeWPF.Services.Encode e.Error ? new EventArgs.EncodeCompletedEventArgs(false, null, string.Empty, this.currentTask.Destination, hbLog, filesize) : new EventArgs.EncodeCompletedEventArgs(true, null, string.Empty, this.currentTask.Destination, hbLog, filesize)); - - // Cleanup - try - { - this.instance.EncodeCompleted -= this.InstanceEncodeCompleted; - this.instance.EncodeProgress -= this.InstanceEncodeProgress; - this.instance.Dispose(); - this.instance = null; - } - catch (Exception exc) - { - this.ServiceLogMessage("Failed to cleanup Encode instance: " + exc ); - } } private long GetFilesize(string destination) |