mirror of
https://github.com/microsoft/PowerToys
synced 2024-11-22 00:03:48 +00: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
@ -87,12 +87,19 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void LoadKBMSettingsFromJson()
|
private void LoadKBMSettingsFromJson()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
KeyboardManagerProfile kbmProfile = GetKBMProfile();
|
KeyboardManagerProfile kbmProfile = GetKBMProfile();
|
||||||
_kbmItem.RemapKeys = kbmProfile?.RemapKeys.InProcessRemapKeys;
|
_kbmItem.RemapKeys = kbmProfile?.RemapKeys.InProcessRemapKeys;
|
||||||
_kbmItem.RemapShortcuts = KeyboardManagerViewModel.CombineShortcutLists(kbmProfile?.RemapShortcuts.GlobalRemapShortcuts, kbmProfile?.RemapShortcuts.AppSpecificRemapShortcuts);
|
_kbmItem.RemapShortcuts = KeyboardManagerViewModel.CombineShortcutLists(kbmProfile?.RemapShortcuts.GlobalRemapShortcuts, kbmProfile?.RemapShortcuts.AppSpecificRemapShortcuts);
|
||||||
dispatcher.Invoke(new Action(() => UpdateKBMItems()));
|
dispatcher.Invoke(new Action(() => UpdateKBMItems()));
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.LogError($"Failed to load KBM settings: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void UpdateKBMItems()
|
private void UpdateKBMItems()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user