mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 19:57:57 +01:00
[Settings][KBM] Fix re-reading loop on non-existing file (#18374)
* [KBM] * [KBM] Keyboard Manager profile loading should not expect the profile to exist
This commit is contained in:
@@ -239,11 +239,12 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
|||||||
[SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Exceptions here (especially mutex errors) should not halt app execution, but they will be logged.")]
|
[SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Exceptions here (especially mutex errors) should not halt app execution, but they will be logged.")]
|
||||||
public bool LoadProfile()
|
public bool LoadProfile()
|
||||||
{
|
{
|
||||||
// The KBM process out of runner creates the default.json file if it does not exist.
|
|
||||||
var success = true;
|
var success = true;
|
||||||
var readSuccessfully = false;
|
var readSuccessfully = false;
|
||||||
|
|
||||||
|
// The KBM process out of runner doesn't create the default.json file if it does not exist.
|
||||||
string fileName = Settings.Properties.ActiveConfiguration.Value + JsonFileType;
|
string fileName = Settings.Properties.ActiveConfiguration.Value + JsonFileType;
|
||||||
|
var profileExists = false;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -253,7 +254,12 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
|||||||
{
|
{
|
||||||
while (!readSuccessfully && !ts.IsCancellationRequested)
|
while (!readSuccessfully && !ts.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
if (_settingsUtils.SettingsExists(PowerToyName, fileName))
|
profileExists = _settingsUtils.SettingsExists(PowerToyName, fileName);
|
||||||
|
if (!profileExists)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -298,7 +304,11 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
|||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!success)
|
if (!profileExists)
|
||||||
|
{
|
||||||
|
Logger.LogInfo($"Couldn't load {PowerToyName} profile because it doesn't exist");
|
||||||
|
}
|
||||||
|
else if (!success)
|
||||||
{
|
{
|
||||||
Logger.LogError($"Couldn't load {PowerToyName} profile");
|
Logger.LogError($"Couldn't load {PowerToyName} profile");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user