From 375c2db84443d90fc1ce8be57c47317bfdde3ad2 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Sat, 26 Aug 2023 22:10:13 +0100 Subject: [PATCH] Fix index calculation in grid submenu Fixes https://gitlab.com/kicad/code/kicad/-/issues/15514 --- common/tool/grid_menu.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/common/tool/grid_menu.cpp b/common/tool/grid_menu.cpp index 2e999d3064..5579f0b8ea 100644 --- a/common/tool/grid_menu.cpp +++ b/common/tool/grid_menu.cpp @@ -68,7 +68,7 @@ void GRID_MENU::UpdateTitle() void GRID_MENU::update() { APP_SETTINGS_BASE* settings = m_parent->config(); - unsigned int current = settings->m_Window.grid.last_size_idx; + unsigned int current = settings->m_Window.grid.last_size_idx + ID_POPUP_GRID_START; wxArrayString gridsList; int i = ID_POPUP_GRID_START; @@ -78,7 +78,10 @@ void GRID_MENU::update() Delete( FindItemByPosition( 0 ) ); for( const wxString& grid : gridsList ) - Append( i++, grid, wxEmptyString, wxITEM_CHECK )->Check( i == (int) current ); + { + int idx = i++; + Append( idx, grid, wxEmptyString, wxITEM_CHECK )->Check( idx == (int) current ); + } } void GRID_MENU::BuildChoiceList( wxArrayString* aGridsList, APP_SETTINGS_BASE* aCfg,