]> granicus.if.org Git - handbrake/commitdiff
WinGui: Strip out some out some legacy code that was causing some threading issues.
authorsr55 <sr55.hb@outlook.com>
Thu, 13 Apr 2017 18:46:15 +0000 (19:46 +0100)
committersr55 <sr55.hb@outlook.com>
Thu, 13 Apr 2017 18:46:15 +0000 (19:46 +0100)
14 files changed:
win/CS/HandBrakeWPF/App.xaml.cs
win/CS/HandBrakeWPF/HandBrakeWPF.csproj
win/CS/HandBrakeWPF/Model/Audio/AudioBehaviourTrack.cs
win/CS/HandBrakeWPF/Model/Audio/AudioBehaviours.cs
win/CS/HandBrakeWPF/Model/Subtitles/SubtitleBehaviours.cs
win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs
win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioTrack.cs
win/CS/HandBrakeWPF/Services/Encode/Model/Models/ChapterMarker.cs
win/CS/HandBrakeWPF/Services/Encode/Model/Models/SubtitleTrack.cs
win/CS/HandBrakeWPF/Services/Presets/Model/Preset.cs
win/CS/HandBrakeWPF/Services/Queue/Model/QueueTask.cs
win/CS/HandBrakeWPF/Utilities/Execute.cs [deleted file]
win/CS/HandBrakeWPF/Utilities/PropertyChangedBase.cs [deleted file]
win/CS/HandBrakeWPF/ViewModels/LogViewModel.cs

index 85f4e39028023d60348549153b09856056b09e19..39eb6c0bc3338019919eb011ed3f869b69dc619d 100644 (file)
@@ -94,15 +94,17 @@ namespace HandBrakeWPF
         /// </param>\r
         private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)\r
         {\r
-            if (e.ExceptionObject.GetType() == typeof(FileNotFoundException))\r
-            {\r
-                GeneralApplicationException exception = new GeneralApplicationException("A file appears to be missing.", "Try re-installing Microsoft .NET Framework 4.0", (Exception)e.ExceptionObject);\r
-                this.ShowError(exception);\r
-            }\r
-            else\r
-            {\r
-                this.ShowError(e.ExceptionObject);\r
-            }\r
+            Caliburn.Micro.Execute.OnUIThreadAsync(() => {\r
+                if (e.ExceptionObject.GetType() == typeof(FileNotFoundException))\r
+                {\r
+                    GeneralApplicationException exception = new GeneralApplicationException("A file appears to be missing.", "Try re-installing Microsoft .NET Framework 4.0", (Exception)e.ExceptionObject);\r
+                    this.ShowError(exception);\r
+                }\r
+                else\r
+                {\r
+                    this.ShowError(e.ExceptionObject);\r
+                }\r
+            });\r
         }\r
 \r
         /// <summary>\r
index 04a73604e09703e60a42db94b1dab6ad8fd0823b..44c58bc0fee7d6e92b7e8e9cee9082a3f1f795ed 100644 (file)
     <Compile Include="Utilities\DPIAwareness.cs" />\r
     <Compile Include="Utilities\DriveUtilities.cs" />\r
     <Compile Include="Utilities\EnumHelper.cs" />\r
-    <Compile Include="Utilities\Execute.cs" />\r
     <Compile Include="Utilities\ExtensionMethods.cs" />\r
     <Compile Include="Utilities\GeneralUtilities.cs" />\r
     <Compile Include="Utilities\HandBrakeApp.cs" />\r
     <Compile Include="Utilities\Interfaces\INotifyPropertyChangedEx.cs" />\r
     <Compile Include="Utilities\Output\CsvHelper.cs" />\r
     <Compile Include="Utilities\Portable.cs" />\r
-    <Compile Include="Utilities\PropertyChangedBase.cs" />\r
     <Compile Include="Utilities\DirectoryUtilities.cs" />\r
     <Compile Include="Utilities\SystemInfo.cs" />\r
     <Compile Include="Utilities\Win32.cs" />\r
index c59b15b8cbd1b4bd5c9cfda2655bce8e52ba9d68..1297ecb716b6d3d6584a52f628951257e9acf4ad 100644 (file)
@@ -13,6 +13,9 @@ namespace HandBrakeWPF.Model.Audio
     using System.ComponentModel;
     using System.Globalization;
     using System.Linq;
+
+    using Caliburn.Micro;
+
     using HandBrake.ApplicationServices.Interop;
     using HandBrake.ApplicationServices.Interop.Model;
     using HandBrake.ApplicationServices.Interop.Model.Encoding;
index b0f81d0c4a7465dec1b5981776543551d5f4880a..aa448d69033a0b16e7f8c3e8525835707087882e 100644 (file)
@@ -12,7 +12,7 @@ namespace HandBrakeWPF.Model.Audio
     using System.ComponentModel;\r
     using System.Linq;\r
 \r
-    using HandBrakeWPF.Utilities;\r
+    using Caliburn.Micro;\r
 \r
     /// <summary>\r
     /// Audio Behaviours\r
index 11200b450a6635530c2177cf32c9d5b878f36560..a6245c9c9642c58e2c6309998e3a91ff1d103376 100644 (file)
@@ -12,7 +12,7 @@ namespace HandBrakeWPF.Model.Subtitles
     using System.ComponentModel;\r
     using System.Linq;\r
 \r
-    using HandBrakeWPF.Utilities;\r
+    using Caliburn.Micro;\r
 \r
     /// <summary>\r
     ///  A class to track the behaviours of audio track selection\r
index 9663ae66c5eb5b4b580ea4a095f6a85c07350ae6..4d0da57fe1f5942755f983743d142fc057557226 100644 (file)
@@ -12,11 +12,12 @@ namespace HandBrakeWPF.Services.Encode.Model
     using System.Collections.Generic;
     using System.Collections.ObjectModel;
 
+    using Caliburn.Micro;
+
     using HandBrake.ApplicationServices.Interop.Model;
     using HandBrake.ApplicationServices.Interop.Model.Encoding;
 
     using HandBrakeWPF.Services.Encode.Model.Models;
-    using HandBrakeWPF.Utilities;
 
     using AllowedPassthru = HandBrakeWPF.Services.Encode.Model.Models.AllowedPassthru;
     using AudioTrack = HandBrakeWPF.Services.Encode.Model.Models.AudioTrack;
index 8d7047a5b24631fd2f872b6339f425db0957f4f3..7cc0731257f2ae40b47e7a9bdb15ded913d833c7 100644 (file)
@@ -14,12 +14,12 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
     using System.ComponentModel;
     using System.Globalization;
     using System.Linq;
-    using System.Security;
+
+    using Caliburn.Micro;
 
     using HandBrake.ApplicationServices.Interop;
     using HandBrake.ApplicationServices.Interop.Model;
     using HandBrake.ApplicationServices.Interop.Model.Encoding;
-    using HandBrake.ApplicationServices.Utilities;
 
     using HandBrakeWPF.Model.Audio;
     using HandBrakeWPF.Services.Scan.Model;
index e2fdb25e341693641e9e8a2b1fbaea0ee3142773..c699ec39c2e67354064ed3adfe895f4ee15cb2f4 100644 (file)
@@ -11,7 +11,7 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
 {
     using System;
 
-    using HandBrakeWPF.Utilities;
+    using Caliburn.Micro;
 
     /// <summary>
     /// A Movie Chapter
index b19fc80f4031bfffb19891be297a5e28728c509e..fe62a5a23d0ca9ed5e08b62295c31c2e231640e1 100644 (file)
@@ -11,10 +11,11 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
 {
     using System;
 
+    using Caliburn.Micro;
+
     using HandBrake.ApplicationServices.Utilities;
 
     using HandBrakeWPF.Services.Scan.Model;
-    using HandBrakeWPF.Utilities;
 
     /// <summary>
     /// Subtitle Information
index 8c0ff34c890f6e031591e8cd56a536e677cf4908..1afeefb94c4396e04521360bfb56f9ddb0845cb6 100644 (file)
@@ -9,10 +9,11 @@
 \r
 namespace HandBrakeWPF.Services.Presets.Model\r
 {\r
+    using Caliburn.Micro;\r
+\r
     using HandBrakeWPF.Model.Audio;\r
     using HandBrakeWPF.Model.Subtitles;\r
     using HandBrakeWPF.Services.Presets.Interfaces;\r
-    using HandBrakeWPF.Utilities;\r
 \r
     using EncodeTask = HandBrakeWPF.Services.Encode.Model.EncodeTask;\r
     using PresetPictureSettingsMode = HandBrakeWPF.Model.Picture.PresetPictureSettingsMode;\r
@@ -20,11 +21,6 @@ namespace HandBrakeWPF.Services.Presets.Model
     /// <summary>\r
     /// A Preset for encoding with.\r
     /// </summary>\r
-    /// <remarks>\r
-    /// Using App Services PropertyChangedBase because Caliburn Micro has [DataContract] on their base class which causes json.net not to serialise properties without [DataContract]\r
-    /// https://github.com/Caliburn-Micro/Caliburn.Micro/issues/89\r
-    /// https://github.com/Caliburn-Micro/Caliburn.Micro/issues/96\r
-    /// </remarks>\r
     public class Preset : PropertyChangedBase, IPresetObject // Delibery not \r
     {\r
         #region Constants and Fields\r
index ac1b28d943ab691aa848cbc3db6971393407e0a9..e8813930d586974b666b065d922b95a013b1d54f 100644 (file)
@@ -9,9 +9,9 @@
 \r
 namespace HandBrakeWPF.Services.Queue.Model\r
 {\r
-    using HandBrake.ApplicationServices.Model;\r
+    using Caliburn.Micro;\r
 \r
-    using HandBrakeWPF.Utilities;\r
+    using HandBrake.ApplicationServices.Model;\r
 \r
     using EncodeTask = HandBrakeWPF.Services.Encode.Model.EncodeTask;\r
 \r
diff --git a/win/CS/HandBrakeWPF/Utilities/Execute.cs b/win/CS/HandBrakeWPF/Utilities/Execute.cs
deleted file mode 100644 (file)
index 0282744..0000000
+++ /dev/null
@@ -1,153 +0,0 @@
-// --------------------------------------------------------------------------------------------------------------------
-// <copyright company="HandBrake Project (http://handbrake.fr)" file="Execute.cs">
-//   This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-//   Enables easy marshalling of code to the UI thread.
-//   Borrowed from Caliburn Micro.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrakeWPF.Utilities
-{
-    using System;
-    using System.ComponentModel;
-    using System.Diagnostics;
-    using System.Threading.Tasks;
-    using System.Windows;
-    using System.Windows.Threading;
-
-    /// <summary>
-    /// Enables easy marshalling of code to the UI thread.
-    /// </summary>
-    public static class Execute
-    {
-        private static System.Action<System.Action> executor = (System.Action<System.Action>)(action => action());
-        private static Dispatcher dispatcher;
-        private static bool? inDesignMode;
-
-        /// <summary>
-        /// Gets a value indicating whether or not the framework is in design-time mode.
-        /// </summary>
-        public static bool InDesignMode
-        {
-            get
-            {
-                if (!Execute.inDesignMode.HasValue)
-                {
-                    Execute.inDesignMode = new bool?((bool)DependencyPropertyDescriptor.FromProperty(DesignerProperties.IsInDesignModeProperty, typeof(FrameworkElement)).Metadata.DefaultValue);
-                    if (!Execute.inDesignMode.GetValueOrDefault(false) && Process.GetCurrentProcess().ProcessName.StartsWith("devenv", StringComparison.Ordinal))
-                        Execute.inDesignMode = new bool?(true);
-                }
-                return Execute.inDesignMode.GetValueOrDefault(false);
-            }
-        }
-
-        /// <summary>
-        /// Initializes the framework using the current dispatcher.
-        /// </summary>
-        public static void InitializeWithDispatcher()
-        {
-            Execute.dispatcher = Dispatcher.CurrentDispatcher;
-            Execute.executor = (System.Action<System.Action>)null;
-        }
-
-        /// <summary>
-        /// Resets the executor to use a non-dispatcher-based action executor.
-        /// </summary>
-        public static void ResetWithoutDispatcher()
-        {
-            executor = (System.Action<System.Action>)(action => action());
-            dispatcher = (Dispatcher)null;
-        }
-
-        /// <summary>
-        /// Sets a custom UI thread marshaller.
-        /// </summary>
-        /// <param name="marshaller">The marshaller.</param>
-        [Obsolete]
-        public static void SetUIThreadMarshaller(System.Action<System.Action> marshaller)
-        {
-            Execute.executor = marshaller;
-            Execute.dispatcher = (Dispatcher)null;
-        }
-
-        /// <summary>
-        /// Executes the action on the UI thread asynchronously.
-        /// </summary>
-        /// <param name="action">The action to execute.</param>
-        public static void BeginOnUIThread(this System.Action action)
-        {
-            Execute.ValidateDispatcher();
-            Execute.dispatcher.BeginInvoke((Delegate)action);
-        }
-
-        /// <summary>
-        /// Executes the action on the UI thread asynchronously.
-        /// </summary>
-        /// <param name="action">
-        /// The action to execute.
-        /// </param>
-        /// <returns>
-        /// The <see cref="Task"/>.
-        /// </returns>
-        public static Task OnUIThreadAsync(this System.Action action)
-        {
-            Execute.ValidateDispatcher();
-            TaskCompletionSource<object> taskSource = new TaskCompletionSource<object>();
-            System.Action action1 = (System.Action)(() =>
-            {
-                try
-                {
-                    action();
-                    taskSource.SetResult((object)null);
-                }
-                catch (Exception ex)
-                {
-                    taskSource.SetException(ex);
-                }
-            });
-            Execute.dispatcher.BeginInvoke((Delegate)action1);
-            return (Task)taskSource.Task;
-        }
-
-        /// <summary>
-        /// Executes the action on the UI thread.
-        /// </summary>
-        /// <param name="action">The action to execute.</param>
-        public static void OnUIThread(this System.Action action)
-        {
-            if (Execute.executor != null)
-                Execute.executor(action);
-            else if (Execute.CheckAccess())
-                action();
-            else
-                Execute.OnUIThreadAsync(action).Wait();
-        }
-
-        /// <summary>
-        /// The check access.
-        /// </summary>
-        /// <returns>
-        /// The <see cref="bool"/>.
-        /// </returns>
-        private static bool CheckAccess()
-        {
-            if (Execute.dispatcher != null)
-                return Execute.dispatcher.CheckAccess();
-            return true;
-        }
-
-        /// <summary>
-        /// The validate dispatcher.
-        /// </summary>
-        /// <exception cref="InvalidOperationException">
-        /// Not initialized with dispatcher.
-        /// </exception>
-        private static void ValidateDispatcher()
-        {
-            if (Execute.dispatcher == null)
-                throw new InvalidOperationException("Not initialized with dispatcher.");
-        }
-    }
-}
diff --git a/win/CS/HandBrakeWPF/Utilities/PropertyChangedBase.cs b/win/CS/HandBrakeWPF/Utilities/PropertyChangedBase.cs
deleted file mode 100644 (file)
index 08f2068..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-// --------------------------------------------------------------------------------------------------------------------
-// <copyright company="HandBrake Project (http://handbrake.fr)" file="PropertyChangedBase.cs">
-//   This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-//   A base class that implements the infrastructure for property change notification and automatically performs UI thread marshalling.
-//   Borrowed from Caliburn Micro
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrakeWPF.Utilities
-{
-    using System;
-    using System.ComponentModel;
-    using System.Linq.Expressions;
-    using System.Runtime.Serialization;
-
-    using INotifyPropertyChangedEx = HandBrakeWPF.Utilities.Interfaces.INotifyPropertyChangedEx;
-
-    /// <summary>
-    /// A base class that implements the infrastructure for property change notification and automatically performs UI thread marshalling.
-    /// </summary>
-    [Serializable]
-    public class PropertyChangedBase : INotifyPropertyChangedEx, INotifyPropertyChanged
-    {
-        [NonSerialized]
-        private bool isNotifying;
-
-        /// <summary>
-        /// Gets or sets a value indicating whether the Enables/Disables property change notification.
-        /// </summary>
-        [Browsable(false)]
-        public bool IsNotifying
-        {
-            get
-            {
-                return this.isNotifying;
-            }
-            set
-            {
-                this.isNotifying = value;
-            }
-        }
-
-        /// <summary>
-        /// Occurs when a property value changes.
-        /// </summary>
-        public event PropertyChangedEventHandler PropertyChanged = (param0, param1) => { };
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="PropertyChangedBase"/> class. 
-        /// Creates an instance of <see cref="T:HandBrakeWPF.Utilities.PropertyChangedBase"/>.
-        /// </summary>
-        public PropertyChangedBase()
-        {
-            this.IsNotifying = true;
-        }
-
-        /// <summary>
-        /// Raises a change notification indicating that all bindings should be refreshed.
-        /// </summary>
-        public void Refresh()
-        {
-            this.NotifyOfPropertyChange(string.Empty);
-        }
-
-        /// <summary>
-        /// Notifies subscribers of the property change.
-        /// </summary>
-        /// <param name="propertyName">Name of the property.</param>
-        public virtual void NotifyOfPropertyChange(string propertyName)
-        {
-            if (!this.IsNotifying)
-                return;
-            Execute.OnUIThread((System.Action)(() => this.OnPropertyChanged(new PropertyChangedEventArgs(propertyName))));
-        }
-
-        /// <summary>
-        /// Notifies subscribers of the property change.
-        /// </summary>
-        /// <typeparam name="TProperty">The type of the property.</typeparam><param name="property">The property expression.</param>
-        public void NotifyOfPropertyChange<TProperty>(Expression<Func<TProperty>> property)
-        {
-            this.NotifyOfPropertyChange(ExtensionMethods.GetMemberInfo((Expression)property).Name);
-        }
-
-        /// <summary>
-        /// Called when the object is deserialized.
-        /// </summary>
-        /// <param name="c">The streaming context.</param>
-        [OnDeserialized]
-        public void OnDeserialized(StreamingContext c)
-        {
-            this.IsNotifying = true;
-        }
-
-        /// <summary>
-        /// Used to indicate whether or not the IsNotifying property is serialized to Xml.
-        /// </summary>
-        /// <returns>
-        /// Whether or not to serialize the IsNotifying property. The default is false.
-        /// </returns>
-        public virtual bool ShouldSerializeIsNotifying()
-        {
-            return false;
-        }
-
-        /// <summary>
-        /// Raises the <see cref="E:PropertyChanged"/> event directly.
-        /// </summary>
-        /// <param name="e">The <see cref="T:System.ComponentModel.PropertyChangedEventArgs"/> instance containing the event data.</param>
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        protected void OnPropertyChanged(PropertyChangedEventArgs e)
-        {
-            PropertyChangedEventHandler changedEventHandler = this.PropertyChanged;
-            if (changedEventHandler == null)
-                return;
-            changedEventHandler((object)this, e);
-        }
-    }
-}
index 85ac495ffcf054bcb557ad2803b76c1d49a6f42d..3fcb4c96c0f84a05071d9a1c568161eabc9ce814 100644 (file)
@@ -14,6 +14,8 @@ namespace HandBrakeWPF.ViewModels
     using System.Text;\r
     using System.Windows;\r
 \r
+    using Caliburn.Micro;\r
+\r
     using HandBrake.ApplicationServices.Services.Logging;\r
     using HandBrake.ApplicationServices.Services.Logging.EventArgs;\r
     using HandBrake.ApplicationServices.Services.Logging.Model;\r