#13723·slint

GridLayout: repeated Row panics in layout.rs col_or_row_and_span when a row changes and the model grows in one batch

Author: tilladamCreated Sep 30, 2026Updated Sep 30, 2026
Labelsa:layoutsneed triaging

Bug: A GridLayout with a repeated Row panics in the grid solver when a row is changed in place and the model grows before the next frame, if a changed handler reads the cell's grid-assigned geometry.

thread panicked at internal/core/layout.rs:567:10:
index out of bounds: the len is 8 but the index is 8

Reproduces on 1.18.0, 1.18.1 and current master (5ccf5b32ce), Rust code generator only. The same .slint driven through slint-interpreter with the same model operations does not panic.

Reduced test case

tests/cases/layout/issue_13723_grid_repeated_row_grow.slint, fails with the Rust test driver on master:

slint
export struct RowData { v: int }

export component TestCase inherits Window {
    width: 300px;
    height: 300px;

    in property <[RowData]> rows;
    out property <int> width-changes;

    GridLayout {
        for r in root.rows: Row {
            Rectangle {
                min-width: 20px + r.v * 1px;
                min-height: 20px;
                changed width => { root.width-changes += 1; }
            }
        }
    }

    out property <bool> test: true;
}
rust
let instance = TestCase::new().unwrap();
let rows = Rc::new(VecModel::from(vec![RowData { v: 0 }]));
instance.set_rows(rows.clone().into());
slint_testing::mock_elapsed_time(16);

// Change row 0 in place and grow the model before the next frame.
rows.set_row_data(0, RowData { v: 5 });
rows.push(RowData { v: 0 });
slint_testing::mock_elapsed_time(16);   // panics here
SLINT_TEST_FILTER=issue_13723 cargo test --manifest-path tests/Cargo.toml -p test-driver-rust

Expected

Two rows, no panic. Row 0's cell is 25px wide, row 1's 20px.

Trigger conditions

All four are needed; removing any one makes it pass (each checked as a separate control):

  1. a repeated Row in a GridLayout;
  2. a cell size bound to the row data (min-width: 20px + r.v * 1px);
  3. a changed handler on the cell's grid-assigned geometry (changed width on the cell, or a child's changed on a property bound to the cell's x/width);
  4. in one batch, before the next frame: a set_row_data that actually changes the row, and a row-count increase (push or insert; the order doesn't matter).

Not triggering: growth in its own frame; shrink instead of grow; set_row_data with the current value; set_vec with the grown contents; a changed handler on a non-geometry property.

Backtrace (master)

col_or_row_and_span
max_value
grid_internal::to_layout_data
solve_grid_layout
InnerTestCase::init::{closure#2}          (the layout-cache binding)
... property binding evaluation ...
ChangeTracker::run_change_handlers
i_slint_backend_testing::mock_elapsed_time

col_or_row_and_span indexes the organized-cell vector (4 u16 per cell). "len 8, index 8" is a lookup of a third cell in data organized for two: to_layout_data iterates over a constraints list that already holds the grown row count while the organized data still describes the old one. The changed handler forces the layout solve from inside run_change_handlers rather than at the next render. That last paragraph is inferred from the stack and the trigger conditions, not verified in the generator.