Don't import invalid polygons.

If we *do* get a 2-point polygon in SVG, import it as a segment.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17091

(cherry picked from commit dba2fdb6d3)
This commit is contained in:
Jeff Young 2024-02-25 12:27:52 +00:00
parent 1c639714f3
commit 2b09653abb
3 changed files with 6 additions and 3 deletions

View File

@ -261,7 +261,7 @@ void SVG_IMPORT_PLUGIN::DrawPath( const float* aPoints, int aNumPoints, bool aCl
if( aNumPoints > 0 )
DrawCubicBezierPath( aPoints, aNumPoints, collectedPathPoints );
if( aClosedPath )
if( aClosedPath && collectedPathPoints.size() > 2 )
DrawPolygon( collectedPathPoints, aStroke, aFilled, aFillColor );
else
DrawLineSegments( collectedPathPoints, aStroke );

View File

@ -176,6 +176,7 @@ void GRAPHICS_IMPORTER_LIB_SYMBOL::AddPolygon( const std::vector<VECTOR2D>& aVer
polygon->SetStroke( MapStrokeParams( aStroke ) );
if( polygon->IsPolyShapeValid() )
addItem( std::move( polygon ) );
}

View File

@ -171,6 +171,8 @@ void GRAPHICS_IMPORTER_PCBNEW::AddPolygon( const std::vector<VECTOR2D>& aVertice
}
polygon->SetStroke( MapStrokeParams( aStroke ) );
if( polygon->IsPolyShapeValid() )
addItem( std::move( polygon ) );
}