Gerbview: fix crash in LAYERS_MAP_DIALOG when trying to use a stored choice,

if no choice exists (new install for instance)

Fixes #4862
https://gitlab.com/kicad/code/kicad/issues/4862
This commit is contained in:
jean-pierre charras 2020-07-11 09:36:59 +02:00
parent 4486b0b6d6
commit a1a8eca844
1 changed files with 5 additions and 1 deletions

View File

@ -307,7 +307,7 @@ void LAYERS_MAP_DIALOG::OnStoreSetup( wxCommandEvent& event )
void LAYERS_MAP_DIALOG::OnGetSetup( wxCommandEvent& event )
{
auto config = static_cast<GERBVIEW_SETTINGS*>( Kiface().KifaceSettings() );
GERBVIEW_SETTINGS* config = static_cast<GERBVIEW_SETTINGS*>( Kiface().KifaceSettings() );
m_exportBoardCopperLayersCount = config->m_BoardLayersCount;
normalizeBrdLayersCount();
@ -317,6 +317,10 @@ void LAYERS_MAP_DIALOG::OnGetSetup( wxCommandEvent& event )
for( int ii = 0; ii < GERBER_DRAWLAYERS_COUNT; ++ii )
{
// Ensure the layer mapping in config exists for this layer, and store it
if( (size_t)ii >= config->m_GerberToPcbLayerMapping.size() )
break;
m_layersLookUpTable[ii] = config->m_GerberToPcbLayerMapping[ ii ];
}