optimize<Preference>: use default preference settings when load broken preference data.

This commit is contained in:
leo 2021-07-13 09:04:28 +08:00
parent 39b5cb54fc
commit 17e9ce2a2f

View file

@ -192,11 +192,15 @@ namespace SourceGit.Models {
if (!File.Exists(SAVE_PATH)) {
instance = new Preference();
} else {
try {
#if NET48
instance = JsonConvert.DeserializeObject<Preference>(File.ReadAllText(SAVE_PATH));
instance = JsonConvert.DeserializeObject<Preference>(File.ReadAllText(SAVE_PATH));
#else
instance = JsonSerializer.Deserialize<Preference>(File.ReadAllText(SAVE_PATH));
instance = JsonSerializer.Deserialize<Preference>(File.ReadAllText(SAVE_PATH));
#endif
} catch {
instance = new Preference();
}
}
if (!instance.IsReady) {