From 0dd34d197ed08d998e964f5ecc6fd8e55d9d6876 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Tue, 16 Jun 2020 19:59:00 -0400 Subject: [PATCH] Ensure currentGrid is valid on startup Fixes https://gitlab.com/kicad/code/kicad/-/issues/4666 --- common/tool/common_tools.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/tool/common_tools.cpp b/common/tool/common_tools.cpp index 65109a5409..f8cb4d62ff 100644 --- a/common/tool/common_tools.cpp +++ b/common/tool/common_tools.cpp @@ -392,6 +392,8 @@ int COMMON_TOOLS::OnGridChanged() { int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx; + currentGrid = std::max( 0, std::min( currentGrid, static_cast( m_grids.size() ) - 1 ) ); + // Update the combobox (if any) wxUpdateUIEvent dummy; m_frame->OnUpdateSelectGrid( dummy );