From e957d10098cb35af9d7487cf010608b9e1f736a6 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Mon, 9 Jun 2025 13:12:10 -0700 Subject: [PATCH] Force grids to have entries. If they don't in the file, reset to the default Fixes https://gitlab.com/kicad/code/kicad/-/issues/21060 --- common/settings/app_settings.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/settings/app_settings.cpp b/common/settings/app_settings.cpp index 491ace9c23..e3a13936ce 100644 --- a/common/settings/app_settings.cpp +++ b/common/settings/app_settings.cpp @@ -455,6 +455,10 @@ void APP_SETTINGS_BASE::addParamsForWindow( WINDOW_SETTINGS* aWindow, const std: m_params.emplace_back( new PARAM_LIST( aJsonPath + ".grid.sizes", &aWindow->grid.grids, DefaultGridSizeList() ) ); + // Force grids to have at least 1 entry. If not, reset to default. + if( aWindow->grid.grids.empty() ) + aWindow->grid.grids = DefaultGridSizeList(); + m_params.emplace_back( new PARAM( aJsonPath + ".grid.last_size", &aWindow->grid.last_size_idx, defaultGridIdx ) );