Skip to content

Guard GridItem.getCellSize against stale row index during item disposal - #707

Draft
wimjongman with Copilot wants to merge 2 commits into
masterfrom
copilot/fix-index-out-of-bounds
Draft

wimjongman with Copilot wants to merge 2 commits into
masterfrom
copilot/fix-index-out-of-bounds

Conversation

Copilot AI commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

When a row is disposed while scrollbar state is changing, GridEditor may re-layout against that row and call GridItem.getCellSize. In that window, the item can already be removed from Grid.items, causing parent.getItem(index) to throw ERROR_INVALID_RANGE.

  • Height computation hardening (GridItem#getCellSize)

    • Stops re-fetching the current item from Grid by row index.
    • Uses getHeight() from the receiver directly.
    • Adds a bounds guard for indexOfCurrentItem before any span traversal over subsequent rows; returns current cell width + own height when index is stale.
  • Regression coverage

    • Adds testDisposeItem_WithEditorAndScrollbarRemoval_DoesNotThrow in GridFixedColumn_Test.
    • Reproduces the failure mode: edited row + vertical scrollbar visibility/values + row dispose.
    • Asserts disposal path no longer throws IllegalArgumentException.
int indexOfCurrentItem = parent.getIndexOfItem(this);
int itemCount = parent.getItemCount();
int height = getHeight();
if (indexOfCurrentItem < 0 || indexOfCurrentItem >= itemCount) {
    return new Point(width, height);
}

Co-authored-by: wimjongman <180969+wimjongman@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix index out of bounds in GridItem.getCellSize Guard GridItem.getCellSize against stale row index during item disposal Sep 8, 2026
Copilot AI requested a review from wimjongman September 8, 2026 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Index out of bounds in GridItem.getCellSize

2 participants