fix<CommitDetail>: crash when request context menu without any change selected

This commit is contained in:
leo 2024-03-02 23:44:49 +08:00
parent 60e664ab26
commit 8ca74d3a9e

View file

@ -19,6 +19,11 @@ namespace SourceGit.Views {
private void OnChangeListContextRequested(object sender, ContextRequestedEventArgs e) { private void OnChangeListContextRequested(object sender, ContextRequestedEventArgs e) {
if (DataContext is ViewModels.CommitDetail detail) { if (DataContext is ViewModels.CommitDetail detail) {
var datagrid = sender as DataGrid; var datagrid = sender as DataGrid;
if (datagrid.SelectedItem == null) {
e.Handled = true;
return;
}
var menu = detail.CreateChangeContextMenu(datagrid.SelectedItem as Models.Change); var menu = detail.CreateChangeContextMenu(datagrid.SelectedItem as Models.Change);
menu.Open(datagrid); menu.Open(datagrid);
} }