Fixed a crash on Eagle PCB import with dimensions on unsupported layers

This commit is contained in:
Maciej Suminski 2017-05-08 11:03:07 +02:00
parent 2ac8ab2a8f
commit 6cefb68c7d
1 changed files with 28 additions and 25 deletions

View File

@ -686,11 +686,14 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
else if( grName == "dimension" )
{
EDIMENSION d( gr );
PCB_LAYER_ID layer = kicad_layer( d.layer );
if( layer != UNDEFINED_LAYER )
{
DIMENSION* dimension = new DIMENSION( m_board );
m_board->Add( dimension, ADD_APPEND );
dimension->SetLayer( kicad_layer( d.layer ) );
dimension->SetLayer( layer );
// The origin and end are assumed to always be in this order from eagle
dimension->SetOrigin( wxPoint( kicad_x( d.x1 ), kicad_y( d.y1 ) ) );
dimension->SetEnd( wxPoint( kicad_x( d.x2 ), kicad_y( d.y2 ) ) );
@ -716,6 +719,7 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
dimension->AdjustDimensionDetails();
}
}
// Get next graphic
gr = gr->GetNext();
@ -1928,8 +1932,7 @@ PCB_LAYER_ID EAGLE_PLUGIN::kicad_layer( int aEagleLayer ) const
case EAGLE_LAYER::USERLAYER2: kiLayer = Eco2_User; break;
default:
// some layers do not map to KiCad
// DBG( printf( "unsupported eagle layer: %d\n", aEagleLayer );)
//
wxASSERT_MSG( false, wxString::Format( "Unsupported Eagle layer %d", aEagleLayer ) );
kiLayer = UNDEFINED_LAYER; break;
}
}