Fix crash with clearance is "too" negative. Same bug as #1663173

Fixes: lp:1663173
* https://bugs.launchpad.net/kicad/+bug/1663173
This commit is contained in:
Jean-Samuel Reynaud 2017-10-19 10:27:00 +02:00 committed by Wayne Stambaugh
parent 56d42c776a
commit 46edf6519c
1 changed files with 37 additions and 16 deletions

View File

@ -402,11 +402,17 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
TransformShapeWithClearanceToPolygon( outline, aDrawInfo.m_PadClearance, SEGCOUNT, 1.0 );
// Draw the polygon: Inflate creates only one convex polygon
SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
if( outline.OutlineCount() > 0 )
{
SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
GRClosedPoly( aClipBox, aDC, poly.PointCount(),
(wxPoint*)&poly.Point( 0 ), false, 0,
aDrawInfo.m_Color, aDrawInfo.m_Color );
if( poly.PointCount() > 0 )
{
GRClosedPoly( aClipBox, aDC, poly.PointCount(),
(wxPoint*)&poly.Point( 0 ), false, 0,
aDrawInfo.m_Color, aDrawInfo.m_Color );
}
}
}
break;
@ -434,11 +440,17 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
TransformRoundRectToPolygon( outline, shape_pos, size, GetOrientation(),
corner_radius, 64 );
SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
if( outline.OutlineCount() > 0 )
{
SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
GRClosedPoly( aClipBox, aDC, poly.PointCount(),
(wxPoint*)&poly.Point( 0 ), aDrawInfo.m_ShowPadFilled, 0,
aDrawInfo.m_Color, aDrawInfo.m_Color );
if( poly.PointCount() > 0 )
{
GRClosedPoly( aClipBox, aDC, poly.PointCount(),
(wxPoint*)&poly.Point( 0 ), aDrawInfo.m_ShowPadFilled, 0,
aDrawInfo.m_Color, aDrawInfo.m_Color );
}
}
}
if( aDrawInfo.m_PadClearance )
@ -452,12 +464,18 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
TransformRoundRectToPolygon( outline, shape_pos, size, GetOrientation(),
corner_radius, 32 );
// Draw the polygon: Inflate creates only one convex polygon
SHAPE_LINE_CHAIN& clearance_poly = outline.Outline( 0 );
if( outline.OutlineCount() > 0 )
{
// Draw the polygon: Inflate creates only one convex polygon
SHAPE_LINE_CHAIN& clearance_poly = outline.Outline( 0 );
GRClosedPoly( aClipBox, aDC, clearance_poly.PointCount(),
(wxPoint*)&clearance_poly.Point( 0 ), false, 0,
aDrawInfo.m_Color, aDrawInfo.m_Color );
if( clearance_poly.PointCount() > 0 )
{
GRClosedPoly( aClipBox, aDC, clearance_poly.PointCount(),
(wxPoint*)&clearance_poly.Point( 0 ), false, 0,
aDrawInfo.m_Color, aDrawInfo.m_Color );
}
}
}
}
break;
@ -541,9 +559,12 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
{
poly = &clearance_outline.Outline( jj );
GRClosedPoly( aClipBox, aDC, poly->PointCount(),
(wxPoint*)&poly->Point( 0 ), false, 0,
aDrawInfo.m_Color, aDrawInfo.m_Color );
if( poly->PointCount() > 0 )
{
GRClosedPoly( aClipBox, aDC, poly->PointCount(),
(wxPoint*)&poly->Point( 0 ), false, 0,
aDrawInfo.m_Color, aDrawInfo.m_Color );
}
}
}
break;