fix: crash when drag & drop on macOS

This commit is contained in:
leo 2024-09-02 09:26:06 +08:00
parent f586979ac5
commit eca37e8d70
No known key found for this signature in database
3 changed files with 7 additions and 4 deletions

View file

@ -43,6 +43,7 @@ namespace SourceGit.Views
private void OnRowHeaderDragOver(object sender, DragEventArgs e)
{
if (DataContext is ViewModels.InteractiveRebase vm &&
e.Data.Contains("InteractiveRebaseItem") &&
e.Data.Get("InteractiveRebaseItem") is ViewModels.InteractiveRebaseItem src &&
sender is Border { DataContext: ViewModels.InteractiveRebaseItem dst } border &&
src != dst)

View file

@ -216,7 +216,8 @@ namespace SourceGit.Views
private void DropTab(object sender, DragEventArgs e)
{
if (e.Data.Get("MovedTab") is ViewModels.LauncherPage moved &&
if (e.Data.Contains("MovedTab") &&
e.Data.Get("MovedTab") is ViewModels.LauncherPage moved &&
sender is Border { DataContext: ViewModels.LauncherPage to } &&
to != moved)
{

View file

@ -73,7 +73,7 @@ namespace SourceGit.Views
}
}
private void OnTreeViewKeyDown(object sender, KeyEventArgs e)
private void OnTreeViewKeyDown(object _, KeyEventArgs e)
{
if (TreeContainer.SelectedItem is ViewModels.RepositoryNode node && e.Key == Key.Enter)
{
@ -163,7 +163,7 @@ namespace SourceGit.Views
private void DropOnTreeView(object sender, DragEventArgs e)
{
if (e.Data.Get("MovedRepositoryTreeNode") is ViewModels.RepositoryNode moved)
if (e.Data.Contains("MovedRepositoryTreeNode") && e.Data.Get("MovedRepositoryTreeNode") is ViewModels.RepositoryNode moved)
{
e.Handled = true;
ViewModels.Welcome.Instance.MoveNode(moved, null);
@ -224,7 +224,8 @@ namespace SourceGit.Views
return;
}
if (e.Data.Get("MovedRepositoryTreeNode") is ViewModels.RepositoryNode moved)
if (e.Data.Contains("MovedRepositoryTreeNode") &&
e.Data.Get("MovedRepositoryTreeNode") is ViewModels.RepositoryNode moved)
{
e.Handled = true;