mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-07 03:45:00 +00:00
refactor: implement IDisposable
instead of calling custom Cleanup
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
550493b572
commit
75b7724d44
8 changed files with 42 additions and 34 deletions
|
@ -12,7 +12,7 @@ using CommunityToolkit.Mvvm.ComponentModel;
|
|||
|
||||
namespace SourceGit.ViewModels
|
||||
{
|
||||
public class Histories : ObservableObject
|
||||
public class Histories : ObservableObject, IDisposable
|
||||
{
|
||||
public Repository Repo
|
||||
{
|
||||
|
@ -57,7 +57,7 @@ namespace SourceGit.ViewModels
|
|||
private set => SetProperty(ref _navigationId, value);
|
||||
}
|
||||
|
||||
public object DetailContext
|
||||
public IDisposable DetailContext
|
||||
{
|
||||
get => _detailContext;
|
||||
set => SetProperty(ref _detailContext, value);
|
||||
|
@ -98,23 +98,13 @@ namespace SourceGit.ViewModels
|
|||
_repo = repo;
|
||||
}
|
||||
|
||||
public void Cleanup()
|
||||
public void Dispose()
|
||||
{
|
||||
Commits = new List<Models.Commit>();
|
||||
|
||||
Commits = [];
|
||||
_repo = null;
|
||||
_graph = null;
|
||||
_autoSelectedCommit = null;
|
||||
|
||||
if (_detailContext is CommitDetail cd)
|
||||
{
|
||||
cd.Cleanup();
|
||||
}
|
||||
else if (_detailContext is RevisionCompare rc)
|
||||
{
|
||||
rc.Cleanup();
|
||||
}
|
||||
|
||||
_detailContext?.Dispose();
|
||||
_detailContext = null;
|
||||
}
|
||||
|
||||
|
@ -220,7 +210,7 @@ namespace SourceGit.ViewModels
|
|||
else
|
||||
{
|
||||
_repo.SelectedSearchedCommit = null;
|
||||
DetailContext = commits.Count;
|
||||
DetailContext = new Models.Count(commits.Count);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1256,7 +1246,7 @@ namespace SourceGit.ViewModels
|
|||
private Models.CommitGraph _graph = null;
|
||||
private Models.Commit _autoSelectedCommit = null;
|
||||
private long _navigationId = 0;
|
||||
private object _detailContext = null;
|
||||
private IDisposable _detailContext = null;
|
||||
|
||||
private Models.Bisect _bisect = null;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue