summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorsr55 <[email protected]>2018-08-13 20:03:21 +0100
committersr55 <[email protected]>2018-08-13 20:03:36 +0100
commit223dc7bd007bfd665948f7e11a9f4681d580cb35 (patch)
tree555d05cf996ed38f3da083749b0c1711def98aec /win
parentd2fc28fc9adfc3da47659cc65e2695c7569ac4c2 (diff)
WinGui: Minor code tidyup.
Diffstat (limited to 'win')
-rw-r--r--win/CS/HandBrake.Interop/Interop/HandBrakeInstance.cs5
-rw-r--r--win/CS/HandBrake.Interop/Interop/HandBrakeInstanceManager.cs14
-rw-r--r--win/CS/HandBrake.Interop/Interop/HandBrakeUtils.cs23
-rw-r--r--win/CS/HandBrake.Interop/Utilities/VersionHelper.cs40
-rw-r--r--win/CS/HandBrakeWPF/Services/Scan/LibScan.cs2
-rw-r--r--win/CS/HandBrakeWPF/Services/UpdateService.cs2
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs2
7 files changed, 37 insertions, 51 deletions
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
/// </summary>
~HandBrakeInstance()
{
- this.Dispose(false);
+ if (this.hbHandle != IntPtr.Zero)
+ {
+ this.Dispose(false);
+ }
}
/// <summary>
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;
/// <summary>
/// Initializes static members of the <see cref="HandBrakeInstanceManager"/> class.
/// </summary>
static HandBrakeInstanceManager()
{
- masterInstance = new HandBrakeInstance();
- masterInstance.Initialize(2);
}
/// <summary>
@@ -95,17 +92,6 @@ namespace HandBrake.Interop.Interop
}
/// <summary>
- /// Gets the master instance.
- /// </summary>
- internal static IHandBrakeInstance MasterInstance
- {
- get
- {
- return masterInstance;
- }
- }
-
- /// <summary>
/// Gets the last scan scan instance.
/// </summary>
internal static IHandBrakeInstance LastScanScanInstance
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
@@ -67,29 +67,6 @@ namespace HandBrake.Interop.Interop
}
/// <summary>
- /// Gets the HandBrake version string.
- /// </summary>
- public static string Version
- {
- get
- {
- var versionPtr = HBFunctions.hb_get_version(IntPtr.Zero); // Pointer isn't actually used.
- return Marshal.PtrToStringAnsi(versionPtr);
- }
- }
-
- /// <summary>
- /// Gets the HandBrake build number.
- /// </summary>
- public static int Build
- {
- get
- {
- return HBFunctions.hb_get_build(IntPtr.Zero);
- }
- }
-
- /// <summary>
/// Ensures the HB global initialize method has been called.
/// </summary>
public static void EnsureGlobalInit()
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;
/// <summary>
/// Version Utility
@@ -25,15 +27,12 @@ namespace HandBrake.Interop.Utilities
/// </returns>
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);
}
/// <summary>
@@ -44,10 +43,31 @@ namespace HandBrake.Interop.Utilities
/// </returns>
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");
+ }
+
+ /// <summary>
+ /// Gets the HandBrake version string.
+ /// </summary>
+ public static string Version
+ {
+ get
+ {
+ var versionPtr = HBFunctions.hb_get_version(IntPtr.Zero); // Pointer isn't actually used.
+ return Marshal.PtrToStringAnsi(versionPtr);
+ }
+ }
+
+ /// <summary>
+ /// Gets the HandBrake build number.
+ /// </summary>
+ public static int Build
+ {
+ get
+ {
+ return HBFunctions.hb_get_build(IntPtr.Zero);
+ }
}
}
}
diff --git a/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs b/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs
index 598758073..e3148866a 100644
--- a/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs
+++ b/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs
@@ -131,7 +131,7 @@ namespace HandBrakeWPF.Services.Scan
this.postScanOperation = postAction;
// Create a new HandBrake Instance.
- this.instance = HandBrake.Interop.Interop.HandBrakeInstanceManager.GetScanInstance(configuraiton.Verbosity);
+ this.instance = HandBrakeInstanceManager.GetScanInstance(configuraiton.Verbosity);
this.instance.ScanProgress += this.InstanceScanProgress;
this.instance.ScanCompleted += this.InstanceScanCompleted;
diff --git a/win/CS/HandBrakeWPF/Services/UpdateService.cs b/win/CS/HandBrakeWPF/Services/UpdateService.cs
index 6a2a289a9..64c909f4d 100644
--- a/win/CS/HandBrakeWPF/Services/UpdateService.cs
+++ b/win/CS/HandBrakeWPF/Services/UpdateService.cs
@@ -109,7 +109,7 @@ namespace HandBrakeWPF.Services
url = Constants.AppcastUnstable64;
}
- var currentBuild = HandBrakeUtils.Build;
+ var currentBuild = VersionHelper.Build;
// Fetch the Appcast from our server.
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
diff --git a/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs
index bbb60f878..7989cd85a 100644
--- a/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs
@@ -150,7 +150,7 @@ namespace HandBrakeWPF.ViewModels
this.Duration = 30;
this.CanPlay = true;
- UseSystemDefaultPlayer = userSettingService.GetUserSetting<bool>(UserSettingConstants.DefaultPlayer);
+ this.useSystemDefaultPlayer = userSettingService.GetUserSetting<bool>(UserSettingConstants.DefaultPlayer);
this.Duration = userSettingService.GetUserSetting<int>(UserSettingConstants.LastPreviewDuration, typeof(int));
}