diff --git a/libs/kimath/src/convert_basic_shapes_to_polygon.cpp b/libs/kimath/src/convert_basic_shapes_to_polygon.cpp index 413e7fc2ab..0a2249f0f4 100644 --- a/libs/kimath/src/convert_basic_shapes_to_polygon.cpp +++ b/libs/kimath/src/convert_basic_shapes_to_polygon.cpp @@ -271,7 +271,7 @@ void CornerListToPolygon( SHAPE_POLY_SET& outline, std::vector& endAngle = EDA_ANGLE( angle, RADIANS_T ); } - if( aInflate ) + if( aInflate && tanAngle2 ) { radius += aInflate; cornerPosition += incoming.Resize( aInflate / tanAngle2 ) diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 189e075b58..bd7fa47bad 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -1370,6 +1370,9 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer ) { const SHAPE_SIMPLE* poly = static_cast( shape ); + if( poly->PointCount() < 2 ) // Careful of empty pads + break; + if( margin.x < 0 ) // The poly shape must be deflated { int numSegs = GetArcToSegmentCount( -margin.x, m_maxError, FULL_CIRCLE ); @@ -1469,7 +1472,9 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer ) // Use ERROR_INSIDE because it avoids Clipper and is therefore much faster. aPad->TransformShapeWithClearanceToPolygon( polySet, ToLAYER_ID( aLayer ), clearance, m_maxError, ERROR_INSIDE ); - m_gal->DrawPolygon( polySet ); + + if( polySet.Outline( 0 ).PointCount() > 2 ) // Careful of empty pads + m_gal->DrawPolygon( polySet ); } } else if( aPad->GetEffectiveHoleShape() && clearance > 0 )