diff --git a/gerbview/gerber_draw_item.cpp b/gerbview/gerber_draw_item.cpp index fe61ac33c0..7a6c4a9463 100644 --- a/gerbview/gerber_draw_item.cpp +++ b/gerbview/gerber_draw_item.cpp @@ -666,17 +666,18 @@ void GERBER_DRAW_ITEM::DrawGbrPoly( EDA_RECT* aClipBox, const wxPoint& aOffset, bool aFilledShape ) { - std::vector points; SHAPE_LINE_CHAIN& poly = m_Polygon.Outline( 0 ); int pointCount = poly.PointCount() - 1; + std::vector points; points.reserve( pointCount ); for( int ii = 0; ii < pointCount; ii++ ) { wxPoint p( poly.Point( ii ).x, poly.Point( ii ).y ); - points[ii] = p + aOffset; - points[ii] = GetABPosition( points[ii] ); + p = p + aOffset; + p = GetABPosition( p ); + points.push_back( p ); } GRClosedPoly( aClipBox, aDC, pointCount, &points[0], aFilledShape, aColor, aColor ); diff --git a/gerbview/gerbview_painter.cpp b/gerbview/gerbview_painter.cpp index 7920d30b25..6f87b74f4e 100644 --- a/gerbview/gerbview_painter.cpp +++ b/gerbview/gerbview_painter.cpp @@ -360,11 +360,16 @@ void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer ) // TODO(JE) Refactor this to allow const aItem D_CODE* code = aItem->GetDcodeDescr(); + if( code && code->m_Shape == APT_RECT ) { if( aItem->m_Polygon.OutlineCount() == 0 ) aItem->ConvertSegmentToPolygon(); - drawPolygon( aItem, aItem->m_Polygon, isFilled ); + + // Warning: drawPolygon modify the polygon to draw, so use a copy + // of aItem->m_Polygon + SHAPE_POLY_SET poly = aItem->m_Polygon; + drawPolygon( aItem, poly, isFilled ); } else {