fix<Clone>: fix crash after clone a new repository

This commit is contained in:
leo 2024-02-22 11:05:20 +08:00
parent faffba09c8
commit 79084c9a9a
4 changed files with 12 additions and 9 deletions

View file

@ -41,9 +41,11 @@ namespace SourceGit.ViewModels {
set => SetProperty(ref _extraArgs, value);
}
public Clone(LauncherPage page) {
View = new Views.Clone() { DataContext = this };
public Clone(Launcher launcher, LauncherPage page) {
_launcher = launcher;
_page = page;
View = new Views.Clone() { DataContext = this };
}
public static ValidationResult ValidateRemote(string remote, ValidationContext _) {
@ -92,14 +94,14 @@ namespace SourceGit.ViewModels {
};
Preference.AddNode(node);
_page.View = new Views.Repository() { DataContext = repo };
_page.Node = node;
_launcher.OpenRepositoryInTab(node, _page);
});
return true;
});
}
private Launcher _launcher = null;
private LauncherPage _page = null;
private string _remote = string.Empty;
private bool _useSSH = false;

View file

@ -106,12 +106,12 @@ namespace SourceGit.ViewModels {
[JsonIgnore]
public int WorkingCopyChangesCount {
get => _workingCopy.Count;
get => _workingCopy == null ? 0 : _workingCopy.Count;
}
[JsonIgnore]
public int StashesCount {
get => _stashesPage.Count;
get => _stashesPage == null ? 0 : _stashesPage.Count;
}
[JsonIgnore]

View file

@ -34,7 +34,8 @@ namespace SourceGit.ViewModels {
}
public void Clone(object param) {
var page = param as LauncherPage;
var launcher = param as Launcher;
var page = launcher.ActivePage;
if (!Preference.Instance.IsGitConfigured) {
App.RaiseException(page.GetId(), App.Text("NotConfigured"));
@ -42,7 +43,7 @@ namespace SourceGit.ViewModels {
}
if (PopupHost.CanCreatePopup()) {
PopupHost.ShowPopup(new Clone(page));
PopupHost.ShowPopup(new Clone(launcher, page));
}
}

View file

@ -15,7 +15,7 @@
<Path Width="15" Height="13" Data="{StaticResource Icons.Folder.Open}"/>
</Button>
<Button Classes="icon_button" Width="32" Command="{Binding Clone}" CommandParameter="{Binding $parent[v:Launcher].DataContext.(vm:Launcher).ActivePage}" ToolTip.Tip="{DynamicResource Text.Welcome.Clone}">
<Button Classes="icon_button" Width="32" Command="{Binding Clone}" CommandParameter="{Binding $parent[v:Launcher].DataContext}" ToolTip.Tip="{DynamicResource Text.Welcome.Clone}">
<Path Width="13" Height="13" Data="{StaticResource Icons.Pull}"/>
</Button>