From 4faf2985f7d8fed49a18c4a81eb624b2d69c12cb Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Sun, 21 Apr 2024 16:43:01 -0500 Subject: [PATCH] Handle error getting keyboard layout (#758) --- RetroBar/Controls/InputLanguage.xaml.cs | 12 ++++++++++-- RetroBar/Utilities/Settings.cs | 2 -- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/RetroBar/Controls/InputLanguage.xaml.cs b/RetroBar/Controls/InputLanguage.xaml.cs index f9b6097a..74c4a3ad 100644 --- a/RetroBar/Controls/InputLanguage.xaml.cs +++ b/RetroBar/Controls/InputLanguage.xaml.cs @@ -4,6 +4,7 @@ using System.Windows.Controls; using System.Windows.Threading; using ManagedShell.Common.Helpers; +using ManagedShell.Common.Logging; using RetroBar.Utilities; namespace RetroBar.Controls @@ -47,8 +48,15 @@ private void Initialize() private void SetLocaleIdentifier() { - var managedShellLayout = KeyboardLayoutHelper.GetKeyboardLayout(false); - LocaleIdentifier = CultureInfo.GetCultureInfo((short)managedShellLayout.HKL); + try + { + var managedShellLayout = KeyboardLayoutHelper.GetKeyboardLayout(false); + LocaleIdentifier = CultureInfo.GetCultureInfo((short)managedShellLayout.HKL); + } + catch (Exception ex) + { + ShellLogger.Error($"Error getting locale identifier: {ex.Message}"); + } } private void StartWatch() diff --git a/RetroBar/Utilities/Settings.cs b/RetroBar/Utilities/Settings.cs index 8a6c5572..db97d29d 100644 --- a/RetroBar/Utilities/Settings.cs +++ b/RetroBar/Utilities/Settings.cs @@ -1,8 +1,6 @@ using ManagedShell.AppBar; -using System; using System.Collections.Generic; using System.ComponentModel; -using System.IO; using System.Runtime.CompilerServices; namespace RetroBar.Utilities