From 223dc7bd007bfd665948f7e11a9f4681d580cb35 Mon Sep 17 00:00:00 2001 From: sr55 Date: Mon, 13 Aug 2018 20:03:21 +0100 Subject: WinGui: Minor code tidyup. --- .../HandBrake.Interop/Interop/HandBrakeInstance.cs | 5 ++- .../Interop/HandBrakeInstanceManager.cs | 14 -------- win/CS/HandBrake.Interop/Interop/HandBrakeUtils.cs | 23 ------------- .../HandBrake.Interop/Utilities/VersionHelper.cs | 40 ++++++++++++++++------ 4 files changed, 34 insertions(+), 48 deletions(-) (limited to 'win/CS/HandBrake.Interop') diff --git a/win/CS/HandBrake.Interop/Interop/HandBrakeInstance.cs b/win/CS/HandBrake.Interop/Interop/HandBrakeInstance.cs index a5aef04a6..c6aa42fe3 100644 --- a/win/CS/HandBrake.Interop/Interop/HandBrakeInstance.cs +++ b/win/CS/HandBrake.Interop/Interop/HandBrakeInstance.cs @@ -90,7 +90,10 @@ namespace HandBrake.Interop.Interop /// ~HandBrakeInstance() { - this.Dispose(false); + if (this.hbHandle != IntPtr.Zero) + { + this.Dispose(false); + } } /// diff --git a/win/CS/HandBrake.Interop/Interop/HandBrakeInstanceManager.cs b/win/CS/HandBrake.Interop/Interop/HandBrakeInstanceManager.cs index 227fa0bd1..76855c5d1 100644 --- a/win/CS/HandBrake.Interop/Interop/HandBrakeInstanceManager.cs +++ b/win/CS/HandBrake.Interop/Interop/HandBrakeInstanceManager.cs @@ -22,15 +22,12 @@ namespace HandBrake.Interop.Interop { private static HandBrakeInstance scanInstance; private static HandBrakeInstance previewInstance; - private static HandBrakeInstance masterInstance; /// /// Initializes static members of the class. /// static HandBrakeInstanceManager() { - masterInstance = new HandBrakeInstance(); - masterInstance.Initialize(2); } /// @@ -94,17 +91,6 @@ namespace HandBrake.Interop.Interop return previewInstance; } - /// - /// Gets the master instance. - /// - internal static IHandBrakeInstance MasterInstance - { - get - { - return masterInstance; - } - } - /// /// Gets the last scan scan instance. /// diff --git a/win/CS/HandBrake.Interop/Interop/HandBrakeUtils.cs b/win/CS/HandBrake.Interop/Interop/HandBrakeUtils.cs index bd8630911..acf4fa15f 100644 --- a/win/CS/HandBrake.Interop/Interop/HandBrakeUtils.cs +++ b/win/CS/HandBrake.Interop/Interop/HandBrakeUtils.cs @@ -66,29 +66,6 @@ namespace HandBrake.Interop.Interop } } - /// - /// Gets the HandBrake version string. - /// - public static string Version - { - get - { - var versionPtr = HBFunctions.hb_get_version(IntPtr.Zero); // Pointer isn't actually used. - return Marshal.PtrToStringAnsi(versionPtr); - } - } - - /// - /// Gets the HandBrake build number. - /// - public static int Build - { - get - { - return HBFunctions.hb_get_build(IntPtr.Zero); - } - } - /// /// Ensures the HB global initialize method has been called. /// diff --git a/win/CS/HandBrake.Interop/Utilities/VersionHelper.cs b/win/CS/HandBrake.Interop/Utilities/VersionHelper.cs index 2975a4793..08c4c95af 100644 --- a/win/CS/HandBrake.Interop/Utilities/VersionHelper.cs +++ b/win/CS/HandBrake.Interop/Utilities/VersionHelper.cs @@ -9,8 +9,10 @@ namespace HandBrake.Interop.Utilities { - using HandBrake.Interop.Interop; - using HandBrake.Interop.Interop.Interfaces; + using System; + using System.Runtime.InteropServices; + + using HandBrake.Interop.Interop.HbLib; /// /// Version Utility @@ -25,15 +27,12 @@ namespace HandBrake.Interop.Utilities /// public static string GetVersion() { - IHandBrakeInstance instance = HandBrakeInstanceManager.MasterInstance; - - return IsNightly() ? string.Format("Nightly {0} ({1})", instance.Version, instance.Build) : string.Format("{0} ({1})", instance.Version, instance.Build); + return IsNightly() ? string.Format("Nightly {0} ({1})", Version, Build) : string.Format("{0} ({1})", Version, Build); } public static string GetVersionShort() { - IHandBrakeInstance instance = HandBrakeInstanceManager.MasterInstance; - return string.Format("{0} {1}", instance.Version, instance.Build); + return string.Format("{0} {1}", Version, Build); } /// @@ -44,10 +43,31 @@ namespace HandBrake.Interop.Utilities /// public static bool IsNightly() { - IHandBrakeInstance instance = HandBrakeInstanceManager.MasterInstance; - // 01 = Unofficial Builds. 00 = Official Tagged Releases. - return instance.Build.ToString().EndsWith("01"); + return Build.ToString().EndsWith("01"); + } + + /// + /// Gets the HandBrake version string. + /// + public static string Version + { + get + { + var versionPtr = HBFunctions.hb_get_version(IntPtr.Zero); // Pointer isn't actually used. + return Marshal.PtrToStringAnsi(versionPtr); + } + } + + /// + /// Gets the HandBrake build number. + /// + public static int Build + { + get + { + return HBFunctions.hb_get_build(IntPtr.Zero); + } } } } -- cgit v1.2.3