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)) { if (!File.Exists(SAVE_PATH)) {
instance = new Preference(); instance = new Preference();
} else { } else {
try {
#if NET48 #if NET48
instance = JsonConvert.DeserializeObject<Preference>(File.ReadAllText(SAVE_PATH)); instance = JsonConvert.DeserializeObject<Preference>(File.ReadAllText(SAVE_PATH));
#else #else
instance = JsonSerializer.Deserialize<Preference>(File.ReadAllText(SAVE_PATH)); instance = JsonSerializer.Deserialize<Preference>(File.ReadAllText(SAVE_PATH));
#endif #endif
} catch {
instance = new Preference();
}
} }
if (!instance.IsReady) { if (!instance.IsReady) {