[Bugfix] Stale last_clicked_cell can be dispatched for a GridView with no grid data #365
Labels
No labels
Alpha Release Requirement
Bugfix
Demo Target
Documentation
Major Feature
Minor Feature
priority:tier1-active
priority:tier2-foundation
priority:tier3-future
priority:tier4-deferred
Refactoring & Cleanup
system:animation
system:documentation
system:grid
system:input
system:performance
system:procgen
system:python-binding
system:rendering
system:ui-hierarchy
Tiny Feature
workflow:blocked
workflow:needs-benchmark
workflow:needs-documentation
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
john/McRogueFace#365
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found by adversarial review of the #355 branch (
feat/355-grid-input-revival,85e4bbe). Reported as minor; not fixed there.Defect
UIGridView::click_athas an early return for the no-data case:It returns
thiswithout clearinglast_clicked_cell. Since #355 madelast_clicked_cellthe channel by whichclick_athands the resolved cell todispatchCellClick(the point cannot be recomputed later —click_atworks in parent-local space,PySceneonly has global), a cell captured by an earlier click survives in that slot.Consequence
If a view's
gridis set toNoneafter a click has already landed on a cell, the next click on that (now dataless) view dispatcheson_cell_clickwith the stale cell from before. A callback fires for a grid that has no cells at all.Narrow, but it is a wrong-data dispatch rather than a missing one, which makes it worth closing.
Fix
Clear
last_clicked_cellon the!grid_datapath (and audit any other early return inclick_atfor the same omission).Test
Click a grid cell, set
grid.grid = None, click again, asserton_cell_clickdoes not fire (or fires with no cell).Fixed on
feat/355-grid-input-revival(11f8394) — but the filed repro was wrongThe defect is real. The mechanism described in the body is not.
"Click a cell, set
grid = None, click again" does not reproduce.dispatchCellClickconsumeslast_clicked_cell(UIGridView.cpp:1326sets it tonulloptafter reading), so a cell that was actually dispatched cannot survive to a later click. I wrote the test straight from the body and it passed against the unfixed build — which is what exposed the gap in the analysis.The real path has two halves.
click_atstashed the cell at step 3 even when it went on to returnnullptrbecause the view had no handlers.dispatchCellClickonly runs on the drawable PyScene got back, and it gotnullptr— so nothing consumed that stash and the cell sat there indefinitely. Then the no-grid_dataearly return hands backthiswithout clearing it.Reproducer (verified failing pre-fix, passing post-fix):
on_cell_click+on_click, then setgrid_data = None.on_cell_clickfires with the stale cell from step 1.Fix: stash only when the view is actually being returned as the click target, and clear on the dataless path. Regression test
tests/regression/issue_365_stale_clicked_cell_test.pycovers that sequence plus a guard that a click resolving to no cell leaves nothing behind. Suite 324/324.Also worth noting for #361: the property is
grid_databut the constructor kwarg isgrid(UIGridView.cpp:573vs:1482). Inconsistent, and a natural thing to reconcile whenGrid/GridView/GridDataget their final names.