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
This commit is contained in:
Jeff Young 2024-02-25 12:27:52 +00:00
parent 4056428a08
commit dba2fdb6d3
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 ) if( aNumPoints > 0 )
DrawCubicBezierPath( aPoints, aNumPoints, collectedPathPoints ); DrawCubicBezierPath( aPoints, aNumPoints, collectedPathPoints );
if( aClosedPath ) if( aClosedPath && collectedPathPoints.size() > 2 )
DrawPolygon( collectedPathPoints, aStroke, aFilled, aFillColor ); DrawPolygon( collectedPathPoints, aStroke, aFilled, aFillColor );
else else
DrawLineSegments( collectedPathPoints, aStroke ); DrawLineSegments( collectedPathPoints, aStroke );

View File

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

View File

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