GerbView: Fix selection of the last two grid settings

Fixes: lp:1827642
* https://bugs.launchpad.net/kicad/+bug/1827642
This commit is contained in:
Jon Evans 2019-05-25 17:14:20 -04:00
parent 5d1dcb4387
commit ba19d93df9
1 changed files with 24 additions and 14 deletions

View File

@ -524,20 +524,24 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
int index = m_gridSelectBox->GetSelection(); int index = m_gridSelectBox->GetSelection();
wxASSERT( index != wxNOT_FOUND ); 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 if( index == int( m_gridSelectBox->GetCount() - 2 ) )
wxUpdateUIEvent dummy; {
OnUpdateSelectGrid( dummy ); // this is the separator
return; wxUpdateUIEvent dummy;
} OnUpdateSelectGrid( dummy );
else if( index == int( m_gridSelectBox->GetCount() - 1 ) ) return;
{ }
wxUpdateUIEvent dummy; else if( index == int( m_gridSelectBox->GetCount() - 1 ) )
OnUpdateSelectGrid( dummy ); {
wxCommandEvent dummy2; wxUpdateUIEvent dummy;
OnGridSettings( dummy2 ); OnUpdateSelectGrid( dummy );
return; wxCommandEvent dummy2;
OnGridSettings( dummy2 );
return;
}
} }
clientData = (int*) m_gridSelectBox->wxItemContainer::GetClientData( index ); clientData = (int*) m_gridSelectBox->wxItemContainer::GetClientData( index );
@ -742,7 +746,13 @@ void EDA_DRAW_FRAME::SetPresetGrid( int aIndex )
if( m_gridSelectBox ) 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" ); wxASSERT_MSG( false, "Invalid grid index" );
return; return;