From edac0266e5b47acaff4ef2af813d2a9bf72d050b Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Wed, 7 May 2025 13:35:21 +1000 Subject: [PATCH] Fix `InputRoll.RowCount`, caused crash on removing row in Lua Console fixes d7b0af9f4 also I think there was an unnecessary copy because this ctor was missing --- src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/Cell.cs | 3 +++ .../CustomControls/InputRoll/InputRoll.cs | 1 + 2 files changed, 4 insertions(+) diff --git a/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/Cell.cs b/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/Cell.cs index 9c168aceb5..f52b07f613 100644 --- a/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/Cell.cs +++ b/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/Cell.cs @@ -92,6 +92,9 @@ namespace BizHawk.Client.EmuHawk public sealed class CellList : SortedList { + private CellList(List wrapped) + : base(wrapped) {} + public CellList() {} public CellList(IEnumerable collection) diff --git a/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs b/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs index 13fb67680f..fe05d32e1d 100644 --- a/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs +++ b/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs @@ -270,6 +270,7 @@ namespace BizHawk.Client.EmuHawk if (_selectedItems.LastOrDefault()?.RowIndex >= _rowCount) { var iLastToKeep = _selectedItems.LowerBoundBinarySearch(static c => c.RowIndex ?? -1, _rowCount); + while (iLastToKeep > -1 && (_selectedItems[iLastToKeep + 1].RowIndex ?? -1) >= _rowCount) iLastToKeep--; _selectedItems = _selectedItems.Slice(start: 0, length: iLastToKeep + 1); }