feature<Launcher>: close tabs by context menu; collect garbage after repository closed

This commit is contained in:
leo 2020-11-30 15:21:45 +08:00
parent a9f138076e
commit 1a46551a77
14 changed files with 145 additions and 103 deletions

View file

@ -50,7 +50,8 @@ namespace SourceGit.UI {
/// Constructor.
/// </summary>
/// <param name="repo">Opened repository.</param>
public Dashboard(Git.Repository opened) {
public Dashboard(Git.Repository opened) {
opened.OnClosing = Cleanup;
opened.OnWorkingCopyChanged = UpdateLocalChanges;
opened.OnTagChanged = UpdateTags;
opened.OnStashChanged = UpdateStashes;
@ -78,6 +79,22 @@ namespace SourceGit.UI {
UpdateSubmodules();
}
/// <summary>
/// Cleanup
/// </summary>
public void Cleanup() {
repo = null;
localBranchTree.ItemsSource = null;
remoteBranchTree.ItemsSource = null;
tagList.ItemsSource = null;
cachedLocalBranches.Clear();
cachedRemotes.Clear();
histories.Cleanup();
commits.Cleanup();
stashes.Cleanup();
}
#region DATA_UPDATE
private void UpdateHistories() {
Dispatcher.Invoke(() => {
@ -287,14 +304,6 @@ namespace SourceGit.UI {
});
});
}
private void Cleanup(object sender, RoutedEventArgs e) {
localBranchTree.ItemsSource = null;
remoteBranchTree.ItemsSource = null;
tagList.ItemsSource = null;
cachedLocalBranches.Clear();
cachedRemotes.Clear();
}
#endregion
#region TOOLBAR
@ -1021,7 +1030,7 @@ namespace SourceGit.UI {
sub.Name = Path.GetFileName(path);
sub.Parent = repo;
if (!sub.BringUpTab()) sub.Open();
App.Open(sub);
}
#endregion