From e81f3961eae7218c90fe37342f06a9830cfdf5d7 Mon Sep 17 00:00:00 2001 From: alterNERDtive Date: Wed, 18 May 2022 13:55:35 +0200 Subject: [PATCH] alterNERDtive-base: fixed settings dialog closing prematurely --- plugins/VoiceAttack-base/SettingsDialog.xaml.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/VoiceAttack-base/SettingsDialog.xaml.cs b/plugins/VoiceAttack-base/SettingsDialog.xaml.cs index 71ef16c..1fe51b2 100644 --- a/plugins/VoiceAttack-base/SettingsDialog.xaml.cs +++ b/plugins/VoiceAttack-base/SettingsDialog.xaml.cs @@ -94,6 +94,8 @@ namespace alterNERDtive private void okButton_Click(object sender, RoutedEventArgs reargs) { + bool error = false; + foreach (Setting setting in values) { dynamic state = null; @@ -130,14 +132,18 @@ namespace alterNERDtive log.Log($@"Configuration changed via settings dialog: ""{setting.Profile}.{setting.Option.Name}"" → ""{state}""", util.LogLevel.DEBUG); config.SetConfig(setting.Profile, setting.Option.Name, state); } - - Window.GetWindow(this).Close(); } catch (Exception e) when (e is ArgumentNullException || e is FormatException || e is OverflowException) { log.Log($@"Invalid value for ""{setting.Profile}.{setting.Option.Name}"": ""{((TextBox)setting.UiElement).Text}""", util.LogLevel.ERROR); + error = true; } } + + if (!error) + { + Window.GetWindow(this).Close(); + } } } }