Tastudio - branches - fix crash when dropping a branch onto an invalid area

This commit is contained in:
adelikat 2015-08-04 21:54:43 -04:00
parent 226fcbb829
commit 15303fd49f
1 changed files with 3 additions and 3 deletions
BizHawk.Client.EmuHawk/tools/TAStudio

View File

@ -305,14 +305,14 @@ namespace BizHawk.Client.EmuHawk
private void BranchView_CellDropped(object sender, InputRoll.CellEventArgs e)
{
if (e.NewCell != null && e.NewCell.IsDataCell)
if (e.NewCell != null && e.NewCell.IsDataCell && e.OldCell.RowIndex.Value < Branches.Count)
{
var branch = Branches[e.OldCell.RowIndex.Value];
int originalIndex = Branches.IndexOf(branch);
int newIndex = e.NewCell.RowIndex.Value;
if (newIndex >= Branches.Count)
newIndex = Branches.Count - 1;
if (newIndex >= Branches.Count)
newIndex = Branches.Count - 1;
Branches.Remove(branch);
Branches.Insert(newIndex, branch);