Follow-up from #144 / PR #146 (surfaced in the multi-agent review of #146).
#144 added >= 2 line-count guards to the Grid class (Grid::validateLineCount, wired into the three factories and setParameter). However, Grid is instantiated only in tests/grids.cpp — it has no production callers.
The user-facing grid generation lives on a separate code path:
VisualizationPanel::generateSourceGrid (src/gui/VisualizationPanel.cpp:275), driven by the "Grid Density" slider (MainWindow.cpp:254).
- That path divides by
m_gridDensity and numContours = m_gridDensity / 2, with only a weaker density > 0 guard (VisualizationPanel.cpp:104).
No live bug today: the slider is clamped to [4, 16], so the denominators are always safe. This is hardening so the GUI path carries an explicit guard equivalent to the Grid class's, rather than relying on the slider clamp.
Scope
- Add an explicit
>= 2 (or appropriate minimum) guard / clamp in generateSourceGrid and setGridDensity so the divisions are well-defined independent of the slider range.
- Consider whether
generateSourceGrid should reuse the Grid class (and thus its validation) rather than duplicating grid math.
Depends on #144 (merged via PR #146).
Follow-up from #144 / PR #146 (surfaced in the multi-agent review of #146).
#144 added
>= 2line-count guards to theGridclass (Grid::validateLineCount, wired into the three factories andsetParameter). However,Gridis instantiated only intests/grids.cpp— it has no production callers.The user-facing grid generation lives on a separate code path:
VisualizationPanel::generateSourceGrid(src/gui/VisualizationPanel.cpp:275), driven by the "Grid Density" slider (MainWindow.cpp:254).m_gridDensityandnumContours = m_gridDensity / 2, with only a weakerdensity > 0guard (VisualizationPanel.cpp:104).No live bug today: the slider is clamped to
[4, 16], so the denominators are always safe. This is hardening so the GUI path carries an explicit guard equivalent to theGridclass's, rather than relying on the slider clamp.Scope
>= 2(or appropriate minimum) guard / clamp ingenerateSourceGridandsetGridDensityso the divisions are well-defined independent of the slider range.generateSourceGridshould reuse theGridclass (and thus its validation) rather than duplicating grid math.Depends on #144 (merged via PR #146).