From ba19d93df97791e9ba3116b8c031ca298c06d004 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sat, 25 May 2019 17:14:20 -0400 Subject: [PATCH] GerbView: Fix selection of the last two grid settings Fixes: lp:1827642 * https://bugs.launchpad.net/kicad/+bug/1827642 --- common/legacy_wx/eda_draw_frame.cpp | 38 ++++++++++++++++++----------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/common/legacy_wx/eda_draw_frame.cpp b/common/legacy_wx/eda_draw_frame.cpp index 905d7385d3..5f1cc6b50f 100644 --- a/common/legacy_wx/eda_draw_frame.cpp +++ b/common/legacy_wx/eda_draw_frame.cpp @@ -524,20 +524,24 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event ) int index = m_gridSelectBox->GetSelection(); wxASSERT( index != wxNOT_FOUND ); - if( index == int( m_gridSelectBox->GetCount() - 2 ) ) + // GerbView does not support custom grid + if( m_Ident != FRAME_GERBER ) { - // this is the separator - wxUpdateUIEvent dummy; - OnUpdateSelectGrid( dummy ); - return; - } - else if( index == int( m_gridSelectBox->GetCount() - 1 ) ) - { - wxUpdateUIEvent dummy; - OnUpdateSelectGrid( dummy ); - wxCommandEvent dummy2; - OnGridSettings( dummy2 ); - return; + if( index == int( m_gridSelectBox->GetCount() - 2 ) ) + { + // this is the separator + wxUpdateUIEvent dummy; + OnUpdateSelectGrid( dummy ); + return; + } + else if( index == int( m_gridSelectBox->GetCount() - 1 ) ) + { + wxUpdateUIEvent dummy; + OnUpdateSelectGrid( dummy ); + wxCommandEvent dummy2; + OnGridSettings( dummy2 ); + return; + } } clientData = (int*) m_gridSelectBox->wxItemContainer::GetClientData( index ); @@ -742,7 +746,13 @@ void EDA_DRAW_FRAME::SetPresetGrid( int aIndex ) if( m_gridSelectBox ) { - if( glistIdx < 0 || glistIdx >= (int) m_gridSelectBox->GetCount() - 2 ) + int highestGrid = ( int )m_gridSelectBox->GetCount(); + + // GerbView does not support the user grid setting + if( m_Ident != FRAME_GERBER ) + highestGrid -= 2; + + if( glistIdx < 0 || glistIdx >= highestGrid ) { wxASSERT_MSG( false, "Invalid grid index" ); return;