From 5bc52e4d55b44e1c46264d284f88658f45b06bf0 Mon Sep 17 00:00:00 2001 From: Robin Krom Date: Wed, 23 Mar 2022 09:45:28 +0100 Subject: [PATCH] Validate the FreehandSensitivity as was reported in BUG-2923. [skip ci] --- .../Configuration/EditorConfiguration.cs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/Greenshot.Editor/Configuration/EditorConfiguration.cs b/src/Greenshot.Editor/Configuration/EditorConfiguration.cs index c36794a5d..9dfb09c23 100644 --- a/src/Greenshot.Editor/Configuration/EditorConfiguration.cs +++ b/src/Greenshot.Editor/Configuration/EditorConfiguration.cs @@ -64,10 +64,7 @@ namespace Greenshot.Editor.Configuration [IniProperty("ReuseEditor", Description = "Reuse already open editor", DefaultValue = "false")] public bool ReuseEditor { get; set; } - [IniProperty("FreehandSensitivity", - Description = - "The smaller this number, the less smoothing is used. Decrease for detailed drawing, e.g. when using a pen. Increase for smoother lines. e.g. when you want to draw a smooth line.", - DefaultValue = "3")] + [IniProperty("FreehandSensitivity", Description = "The smaller this number, the less smoothing is used. Decrease for detailed drawing, e.g. when using a pen. Increase for smoother lines. e.g. when you want to draw a smooth line. Minimal value is 1, max is 2147483647.", DefaultValue = "3")] public int FreehandSensitivity { get; set; } [IniProperty("SuppressSaveDialogAtClose", Description = "Suppressed the 'do you want to save' dialog when closing the editor.", DefaultValue = "False")] @@ -86,9 +83,11 @@ namespace Greenshot.Editor.Configuration public override void AfterLoad() { base.AfterLoad(); - if (RecentColors == null) + RecentColors ??= new List(); + + if (FreehandSensitivity < 1) { - RecentColors = new List(); + FreehandSensitivity = 1; } } @@ -137,10 +136,7 @@ namespace Greenshot.Editor.Configuration { string requestedField = field.Scope + "." + field.FieldType.Name; // Check if the configuration exists - if (LastUsedFieldValues == null) - { - LastUsedFieldValues = new Dictionary(); - } + LastUsedFieldValues ??= new Dictionary(); // check if settings for the requesting type exist, if not create! if (LastUsedFieldValues.ContainsKey(requestedField))