[Bugfix] Grid layer property setters (visible, z_index) don't invalidate the render cache #376
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#376
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 while unrotting
tests/regression/issue_148_layer_dirty_flags.py(part of the #341/#350/#372 batch). Independently reproduced.Defect
Setting
layer.visibledoes not invalidate the grid's render cache, in both directions. Hiding a layer leaves the rendered image byte-identical; re-showing it does not restore it. The change only takes effect once some unrelated mutation happens to dirty the layer.Reproduction (confirmed)
Root cause
src/GridLayers.cpp—PyGridLayerAPI::ColorLayer_set_visible(~line 1723) andTileLayer_set_visible:They never call
markDirty().GridLayer::markDirty()(line 163) is what bumpsparent_grid->content_generation, andcontent_generationis the key theUIGridViewrender early-out (#351) uses to decide whether to re-composite. Every data mutator (fill/set/edit) calls it; the visible setter does not. So the view re-blits its stale cached RenderTexture.The semantics are clearly intended:
GridLayer::render()early-outs on the flag (if (!visible) return;, lines 436 and 622), so the hide renders correctly the moment anything else dirties the layer. Only the invalidation is missing.Same latent defect in z_index
ColorLayer_set_z_index(line 1703) writesz_indexand carries an explicit// TODO: Trigger re-sort in parent grid. Confirmed empirically: reordering two overlapping ColorLayers viaz_indexdoes not change the render either.Both are instances of the same class: layer property setters don't invalidate the grid cache.
Fix
Two lines per setter:
and the equivalent for
z_index(which additionally needs the parent grid's layer re-sort).Why it was never caught
tests/regression/issue_148_layer_dirty_flags.pyis named for exactly this class of defect, but had rotted (it calledadd_layer(name=...), which no longer accepts kwargs) and was silently scored as passing. It exercised the flags via data mutations only, never via thevisiblesetter alone.Note this became observable only after #351 added the render early-out — before that, the unconditional redraw masked it. Same masking story as the entity
set_positionbug #351 fixed.