EAGLE import: fix crash when loading a polygon.
Fixes KICAD-TW
This commit is contained in:
parent
1db9febcfe
commit
bfb6269f0a
|
@ -1439,7 +1439,6 @@ ZONE* EAGLE_PLUGIN::loadPolygon( wxXmlNode* aPolyNode )
|
|||
{
|
||||
EPOLYGON p( aPolyNode );
|
||||
PCB_LAYER_ID layer = kicad_layer( p.layer );
|
||||
ZONE* zone = nullptr;
|
||||
bool keepout = ( p.layer == EAGLE_LAYER::TRESTRICT
|
||||
|| p.layer == EAGLE_LAYER::BRESTRICT
|
||||
|| p.layer == EAGLE_LAYER::VRESTRICT );
|
||||
|
@ -1456,13 +1455,12 @@ ZONE* EAGLE_PLUGIN::loadPolygon( wxXmlNode* aPolyNode )
|
|||
return nullptr;
|
||||
|
||||
// use a "netcode = 0" type ZONE:
|
||||
zone = new ZONE( m_board );
|
||||
m_board->Add( zone, ADD_MODE::APPEND );
|
||||
std::unique_ptr<ZONE> zone = std::make_unique<ZONE>( m_board );
|
||||
|
||||
if( !keepout )
|
||||
zone->SetLayer( layer );
|
||||
else
|
||||
setKeepoutSettingsToZone( zone, p.layer );
|
||||
setKeepoutSettingsToZone( zone.get(), p.layer );
|
||||
|
||||
// Get the first vertex and iterate
|
||||
wxXmlNode* vertex = aPolyNode->GetChildren();
|
||||
|
@ -1528,8 +1526,16 @@ ZONE* EAGLE_PLUGIN::loadPolygon( wxXmlNode* aPolyNode )
|
|||
if( p.width.ToPcbUnits() > 0 )
|
||||
{
|
||||
polygon.Inflate( p.width.ToPcbUnits() / 2, SHAPE_POLY_SET::ALLOW_ACUTE_CORNERS,
|
||||
ARC_HIGH_DEF );
|
||||
polygon.Fracture( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
|
||||
ARC_HIGH_DEF, true );
|
||||
}
|
||||
|
||||
if( polygon.OutlineCount() != 1 )
|
||||
{
|
||||
wxLogMessage( wxString::Format(
|
||||
_( "Skipping a polygon on layer '%s' (%d): outline count is not 1" ),
|
||||
eagle_layer_name( p.layer ), p.layer ) );
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
zone->AddPolygon( polygon.COutline( 0 ) );
|
||||
|
@ -1582,7 +1588,7 @@ ZONE* EAGLE_PLUGIN::loadPolygon( wxXmlNode* aPolyNode )
|
|||
int rank = p.rank ? (p.max_priority - *p.rank) : p.max_priority;
|
||||
zone->SetAssignedPriority( rank );
|
||||
|
||||
return zone;
|
||||
return zone.release();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue