Fix crash while translating subtitles - thx claudemartin :)

Fix #8901
This commit is contained in:
Nikolaj Olsson 2024-10-12 09:27:13 +02:00
parent 172b47cdcb
commit 7c9c32c5dc

View File

@ -1380,17 +1380,22 @@ namespace Nikse.SubtitleEdit.Forms.Translate
private static void SyncListViews(ListView listViewSelected, SubtitleListView listViewOther)
{
if (listViewSelected.SelectedItems.Count > 0)
if (listViewSelected == null ||
listViewOther == null ||
listViewSelected.SelectedItems.Count == 0 ||
listViewSelected.TopItem == null)
{
var first = listViewSelected.TopItem.Index;
var index = listViewSelected.SelectedItems[0].Index;
if (index < listViewOther.Items.Count)
return;
}
var first = listViewSelected.TopItem.Index;
var index = listViewSelected.SelectedItems[0].Index;
if (index < listViewOther.Items.Count)
{
listViewOther.SelectIndexAndEnsureVisible(index, false);
if (first >= 0)
{
listViewOther.SelectIndexAndEnsureVisible(index, false);
if (first >= 0)
{
listViewOther.TopItem = listViewOther.Items[first];
}
listViewOther.TopItem = listViewOther.Items[first];
}
}
}