mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-10-31 13:03:20 -07: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="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
Startup="OnAppStartup"
|
Startup="OnAppStartup"
|
||||||
Deactivated="OnAppDeactivated"
|
Deactivated="OnAppDeactivated">
|
||||||
Exit="OnAppExit">
|
|
||||||
<Application.Resources>
|
<Application.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
|
|
|
@ -119,16 +119,8 @@ namespace SourceGit {
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void OnAppDeactivated(object sender, EventArgs e) {
|
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();
|
Git.Preference.Save();
|
||||||
|
GC.Collect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,10 +134,14 @@ namespace SourceGit.Git {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var stream = new FileStream(SAVE_PATH, FileMode.Open);
|
try {
|
||||||
var reader = new XmlSerializer(typeof(Preference));
|
var stream = new FileStream(SAVE_PATH, FileMode.Open);
|
||||||
instance = (Preference)reader.Deserialize(stream);
|
var reader = new XmlSerializer(typeof(Preference));
|
||||||
stream.Close();
|
instance = (Preference)reader.Deserialize(stream);
|
||||||
|
stream.Close();
|
||||||
|
} catch {
|
||||||
|
instance = new Preference();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -4,7 +4,6 @@ using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Windows.Forms;
|
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue