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