Fix crash due to load invalid preference.xml

This commit is contained in:
leo 2020-07-16 09:26:21 +08:00
parent a82943d649
commit b5002cb89d
4 changed files with 10 additions and 16 deletions

View file

@ -134,10 +134,14 @@ namespace SourceGit.Git {
return;
}
var stream = new FileStream(SAVE_PATH, FileMode.Open);
var reader = new XmlSerializer(typeof(Preference));
instance = (Preference)reader.Deserialize(stream);
stream.Close();
try {
var stream = new FileStream(SAVE_PATH, FileMode.Open);
var reader = new XmlSerializer(typeof(Preference));
instance = (Preference)reader.Deserialize(stream);
stream.Close();
} catch {
instance = new Preference();
}
}
/// <summary>

View file

@ -4,7 +4,6 @@ using System.Diagnostics;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.Windows.Threading;
using System.Xml.Serialization;