mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-03 19:39:07 +08:00
[Settings]Fix crash on dashboard when KBM settings update (#33872)
## Summary of the Pull Request Fixed crash of Settings when KBM settings update by any mechanism. ## Detailed Description of the Pull Request / Additional comments To show updated KBM remappings on the dashboard, the Settings app watches for changes to the KBM settings file and reloads the file on change. Reloading the file can fail (most likely because the writing process takes an exclusive lock and isn't yet done writing) and the process crashes when this happens. This change guards against this.
This commit is contained in:
parent
fb36e6ced9
commit
7457ff5202
@ -88,10 +88,17 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
|
||||
private void LoadKBMSettingsFromJson()
|
||||
{
|
||||
KeyboardManagerProfile kbmProfile = GetKBMProfile();
|
||||
_kbmItem.RemapKeys = kbmProfile?.RemapKeys.InProcessRemapKeys;
|
||||
_kbmItem.RemapShortcuts = KeyboardManagerViewModel.CombineShortcutLists(kbmProfile?.RemapShortcuts.GlobalRemapShortcuts, kbmProfile?.RemapShortcuts.AppSpecificRemapShortcuts);
|
||||
dispatcher.Invoke(new Action(() => UpdateKBMItems()));
|
||||
try
|
||||
{
|
||||
KeyboardManagerProfile kbmProfile = GetKBMProfile();
|
||||
_kbmItem.RemapKeys = kbmProfile?.RemapKeys.InProcessRemapKeys;
|
||||
_kbmItem.RemapShortcuts = KeyboardManagerViewModel.CombineShortcutLists(kbmProfile?.RemapShortcuts.GlobalRemapShortcuts, kbmProfile?.RemapShortcuts.AppSpecificRemapShortcuts);
|
||||
dispatcher.Invoke(new Action(() => UpdateKBMItems()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError($"Failed to load KBM settings: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateKBMItems()
|
||||
|
Loading…
Reference in New Issue
Block a user