Load default config when an invalid config is found (#1008)
- Bind toggle events after setting up their current values. This fixes the issue where the config is saved 10 times when the main window is opened 😬
- Write to disk immediately to decrease the chances of corruption
This commit is contained in:
parent
51f7cc1483
commit
94f93727cf
4 changed files with 50 additions and 35 deletions
|
@ -227,9 +227,20 @@ namespace Ryujinx.Configuration
|
|||
/// Loads a configuration file from disk
|
||||
/// </summary>
|
||||
/// <param name="path">The path to the JSON configuration file</param>
|
||||
public static ConfigurationFileFormat Load(string path)
|
||||
public static bool TryLoad(string path, out ConfigurationFileFormat configurationFileFormat)
|
||||
{
|
||||
return JsonHelper.DeserializeFromFile<ConfigurationFileFormat>(path);
|
||||
try
|
||||
{
|
||||
configurationFileFormat = JsonHelper.DeserializeFromFile<ConfigurationFileFormat>(path);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
configurationFileFormat = null;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -238,7 +249,8 @@ namespace Ryujinx.Configuration
|
|||
/// <param name="path">The path to the JSON configuration file</param>
|
||||
public void SaveConfig(string path)
|
||||
{
|
||||
File.WriteAllText(path, JsonHelper.Serialize(this, true));
|
||||
using FileStream fileStream = File.Create(path, 4096, FileOptions.WriteThrough);
|
||||
JsonHelper.Serialize(fileStream, this, true);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue