Prevent bound sound path grid deletes from leaving stale DataGridView state#1202
Prevent bound sound path grid deletes from leaving stale DataGridView state#1202Copilot wants to merge 2 commits into
Conversation
Agent-Logs-Url: https://github.com/TombEngine/Tomb-Editor/sessions/7195f07c-af45-4b55-989f-6363f0a441dd Co-authored-by: Nickelony <20436882+Nickelony@users.noreply.github.com>
|
@copilot Would you be able to provide reproduction steps for the original issue? What do we have to do in order to get the original error before the fix was applied? Also, please double-check that the changes don't cause any regressions for other places in the code. |
The original repro should be: open a legacy TRLE project, convert it to TEN, go to Level Settings -> Sounds, select a sound sample path row near the bottom of the list so it is also the current row, then delete it. Before 659a77c, the bound list was updated first, I also double-checked the regression risk in the shared delete helper. The only behavior change is that |
Deleting a sound sample path in Level Settings could throw
System.IndexOutOfRangeExceptionafter importing a legacy TRLE project and converting it to TEN. The failure came from the boundDataGridViewdelete path leaving stale current-row/selection state while the underlying list was being mutated.Root cause
The sound path list is backed by a bound collection. Deletion was removing items from the editable row collection while the grid still held a current cell and selected rows that could become invalid mid-update.
Change
The shared
DarkDataGridViewControlsdelete handler now clears grid state before removing rows from the bound collection:CurrentCellSelectedRowsagain after the collection has changedEffect
Bound row deletion no longer depends on
DataGridViewrows that may already be detached, which prevents theCurrencyManagerindex mismatch seen when deleting sound sample paths.