]> granicus.if.org Git - handbrake/commitdiff
WinGui: Fix an integer overflow in the UI layer for the start/stop controls. Fixes...
authorsr55 <sr55.hb@outlook.com>
Thu, 14 Jun 2018 18:56:44 +0000 (19:56 +0100)
committersr55 <sr55.hb@outlook.com>
Thu, 14 Jun 2018 18:57:32 +0000 (19:57 +0100)
win/CS/HandBrakeWPF/Controls/TimeSpanBox.xaml.cs
win/CS/HandBrakeWPF/Converters/LongToIntConverter.cs [new file with mode: 0644]
win/CS/HandBrakeWPF/HandBrakeWPF.csproj
win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs
win/CS/HandBrakeWPF/Services/Scan/Model/Title.cs
win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
win/CS/HandBrakeWPF/Views/MainView.xaml

index 5f983a6996ede1920daef3130099bca0b94c25d3..a8277ec3b9f4310aa7d4c8bfce7b88b1adc94dd1 100644 (file)
@@ -67,7 +67,7 @@ namespace HandBrakeWPF.Controls
         /// The number property.\r
         /// </summary>\r
         public static readonly DependencyProperty NumberProperty = DependencyProperty.Register(\r
-            "Number", typeof(int), typeof(TimeSpanBox), new PropertyMetadata(OnNumberChanged));\r
+            "Number", typeof(long), typeof(TimeSpanBox), new PropertyMetadata(OnNumberChanged));\r
 \r
         /// <summary>\r
         /// The show time span property.\r
@@ -225,11 +225,11 @@ namespace HandBrakeWPF.Controls
         /// <summary>\r
         /// Gets or sets the number.\r
         /// </summary>\r
-        public int Number\r
+        public long Number\r
         {\r
             get\r
             {\r
-                return (int)this.GetValue(NumberProperty);\r
+                return (long)this.GetValue(NumberProperty);\r
             }\r
 \r
             set\r
@@ -337,7 +337,7 @@ namespace HandBrakeWPF.Controls
         /// </summary>\r
         private void DecrementNumber()\r
         {\r
-            int newNumber;\r
+            long newNumber;\r
             if (this.AllowEmpty && this.Number == 0)\r
             {\r
                 newNumber = Math.Min(this.Maximum, -this.Increment);\r
@@ -416,7 +416,7 @@ namespace HandBrakeWPF.Controls
         /// </summary>\r
         private void IncrementNumber()\r
         {\r
-            int newNumber;\r
+            long newNumber;\r
             if (this.AllowEmpty && this.Number == 0)\r
             {\r
                 newNumber = Math.Max(this.Minimum, this.Increment);\r
diff --git a/win/CS/HandBrakeWPF/Converters/LongToIntConverter.cs b/win/CS/HandBrakeWPF/Converters/LongToIntConverter.cs
new file mode 100644 (file)
index 0000000..97b4433
--- /dev/null
@@ -0,0 +1,34 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="LongToIntConverter.cs" company="HandBrake Project (http://handbrake.fr)">
+//   This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+//   Defines the FullPathToFileNameConverter type.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Converters
+{
+    using System;
+    using System.Globalization;
+    using System.Windows.Data;
+
+    public class LongToIntConverter : IValueConverter
+    {
+        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            if (value != null && value is long && (long)value <= int.MaxValue)
+            {
+                long result = (long)value;
+                return (int)result;
+            }
+
+            return (int)0;
+        }
+
+        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            throw new NotImplementedException();
+        }
+    }
+}
index c366fe1c610ea4dd8fd26ad5b9d597677db3365a..0196c7d9136bdc0ad8919b78298ed1e74d7985d8 100644 (file)
     <Compile Include="Converters\Filters\DenoisePresetConverter.cs" />\r
     <Compile Include="Converters\Filters\SharpenTuneConverter.cs" />\r
     <Compile Include="Converters\Filters\SharpenPresetConverter.cs" />\r
+    <Compile Include="Converters\LongToIntConverter.cs" />\r
     <Compile Include="Converters\Options\FileSizeConverter.cs" />\r
     <Compile Include="Converters\Options\LogLevelConverter.cs" />\r
     <Compile Include="Converters\OptionTabConverter.cs" />\r
index f65cf689143ff94cecb82a484a5a4b4d7733cc7d..3efaada5d1cd402f3f53d7e530cb6f5cc1a307c5 100644 (file)
@@ -184,12 +184,12 @@ namespace HandBrakeWPF.Services.Encode.Model
         /// <summary>
         /// Gets or sets StartPoint.
         /// </summary>
-        public int StartPoint { get; set; }
+        public long StartPoint { get; set; }
 
         /// <summary>
         /// Gets or sets EndPoint.
         /// </summary>
-        public int EndPoint { get; set; }
+        public long EndPoint { get; set; }
 
         #endregion
 
index e60520fa75aaa4d1165b6ca99a572a5321f518b3..d83b65f872aa2d35a3ea8ec982ef49e363ee9274 100644 (file)
@@ -181,7 +181,7 @@ namespace HandBrakeWPF.Services.Scan.Model
         /// <param name="startPoint">The Start Point (Chapters)</param>
         /// <param name="endPoint">The End Point (Chapters)</param>
         /// <returns>A Timespan</returns>
-        public TimeSpan CalculateDuration(int startPoint, int endPoint)
+        public TimeSpan CalculateDuration(long startPoint, long endPoint)
         {
             IEnumerable<Chapter> chapers =
                 this.Chapters.Where(c => c.ChapterNumber >= startPoint && c.ChapterNumber <= endPoint);
index 76e3c026e1508677f71694e6fc8a6946737ad2a0..930f8c680ac47d490d409ebcdef15a890d303ac2 100644 (file)
@@ -808,7 +808,7 @@ namespace HandBrakeWPF.ViewModels
         {\r
             get\r
             {\r
-                return this.CurrentTask.StartPoint;\r
+                return this.CurrentTask.Angle;\r
             }\r
 \r
             set\r
@@ -826,12 +826,13 @@ namespace HandBrakeWPF.ViewModels
         /// <summary>\r
         /// Gets or sets SelectedStartPoint.\r
         /// </summary>\r
-        public int SelectedStartPoint\r
+        public long SelectedStartPoint\r
         {\r
             get\r
             {\r
                 return this.CurrentTask.StartPoint;\r
             }\r
+\r
             set\r
             {\r
                 this.CurrentTask.StartPoint = value;\r
@@ -857,12 +858,13 @@ namespace HandBrakeWPF.ViewModels
         /// <summary>\r
         /// Gets or sets SelectedEndPoint.\r
         /// </summary>\r
-        public int SelectedEndPoint\r
+        public long SelectedEndPoint\r
         {\r
             get\r
             {\r
                 return this.CurrentTask.EndPoint;\r
             }\r
+\r
             set\r
             {\r
                 this.CurrentTask.EndPoint = value;\r
@@ -2245,8 +2247,8 @@ namespace HandBrakeWPF.ViewModels
                 // Update the Main Window\r
                 this.NotifyOfPropertyChange(() => this.Destination);\r
                 this.SelectedAngle = this.CurrentTask.Angle;\r
-                int start = this.CurrentTask.StartPoint;\r
-                int end = this.CurrentTask.EndPoint;\r
+                long start = this.CurrentTask.StartPoint;\r
+                long end = this.CurrentTask.EndPoint;\r
                 this.SelectedPointToPoint = this.CurrentTask.PointToPointMode; // Force reset.\r
                 this.SelectedStartPoint = start;\r
                 this.SelectedEndPoint = end;\r
index 049e31a284b80cbb6e05d3b86d39e968d552d532..6ef0673bca39bff371ffb77c4896ce9d55f7248b 100644 (file)
@@ -19,6 +19,7 @@
     <UserControl.Resources>\r
         <Converters:BooleanConverter x:Key="booleanConverter" />\r
         <Converters:PresetsMenuConverter x:Key="presetsMenuConverter"/>\r
+        <Converters:LongToIntConverter x:Key="longToIntConverter" />\r
 \r
         <Style TargetType="Button">\r
             <Setter Property="Padding" Value="8,2" />\r
                                   MinWidth="60"\r
                                   Margin="5,0,0,0"\r
                                   ItemsSource="{Binding StartEndRangeItems}"\r
-                                  SelectedItem="{Binding SelectedStartPoint}"\r
+                                  SelectedItem="{Binding SelectedStartPoint, Converter={StaticResource longToIntConverter}}"\r
                                   ToolTip="{x:Static Properties:ResourcesTooltips.MainView_StartPoint}"\r
                                   Visibility="{Binding ShowTextEntryForPointToPointMode,\r
                                                        Converter={StaticResource boolToVisConverter},\r
                                   MinWidth="60"\r
                                   Margin="4,0,0,0"\r
                                   ItemsSource="{Binding StartEndRangeItems}"\r
-                                  SelectedItem="{Binding SelectedEndPoint}"\r
+                                  SelectedItem="{Binding SelectedEndPoint, Converter={StaticResource longToIntConverter}}"\r
                                   ToolTip="{x:Static Properties:ResourcesTooltips.MainView_EndPoint}"\r
                                   Visibility="{Binding ShowTextEntryForPointToPointMode,\r
                                                        Converter={StaticResource boolToVisConverter},\r