Skip to content

Harden GUI grid generation div paths to match the Grid class guards #147

Description

@ehkropf

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions