mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
Fix crash due to load invalid preference.xml
This commit is contained in:
parent
a82943d649
commit
b5002cb89d
4 changed files with 10 additions and 16 deletions
|
@ -2,8 +2,7 @@
|
|||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Startup="OnAppStartup"
|
||||
Deactivated="OnAppDeactivated"
|
||||
Exit="OnAppExit">
|
||||
Deactivated="OnAppDeactivated">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
|
|
|
@ -119,16 +119,8 @@ namespace SourceGit {
|
|||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OnAppDeactivated(object sender, EventArgs e) {
|
||||
GC.Collect();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Quit event.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OnAppExit(object sender, ExitEventArgs e) {
|
||||
Git.Preference.Save();
|
||||
GC.Collect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue