From 4e76a18d5dc0b45283c41abf167062040d0f8d4b Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sun, 18 Mar 2018 21:55:07 -0400 Subject: [PATCH] Add checks against missing D-Codes in flashed Gerber items Fixes: lp:1756710 * https://bugs.launchpad.net/kicad/+bug/1756710 --- gerbview/gerber_draw_item.cpp | 34 +++++++++++++++++++++++----------- gerbview/gerbview_painter.cpp | 3 +++ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/gerbview/gerber_draw_item.cpp b/gerbview/gerber_draw_item.cpp index 18c8ba8504..93fd35a80a 100644 --- a/gerbview/gerber_draw_item.cpp +++ b/gerbview/gerber_draw_item.cpp @@ -320,37 +320,49 @@ const EDA_RECT GERBER_DRAW_ITEM::GetBoundingBox() const case GBR_SPOT_CIRCLE: { - int radius = code->m_Size.x >> 1; - bbox.Inflate( radius, radius ); + if( code ) + { + int radius = code->m_Size.x >> 1; + bbox.Inflate( radius, radius ); + } break; } case GBR_SPOT_RECT: { - bbox.Inflate( code->m_Size.x / 2, code->m_Size.y / 2 ); + if( code ) + bbox.Inflate( code->m_Size.x / 2, code->m_Size.y / 2 ); break; } case GBR_SPOT_OVAL: { - bbox.Inflate( code->m_Size.x, code->m_Size.y ); + if( code ) + bbox.Inflate( code->m_Size.x, code->m_Size.y ); break; } case GBR_SPOT_POLY: { - if( code->m_Polygon.OutlineCount() == 0 ) - code->ConvertShapeToPolygon(); + if( code ) + { + if( code->m_Polygon.OutlineCount() == 0 ) + code->ConvertShapeToPolygon(); - bbox.Inflate( code->m_Polygon.BBox().GetWidth() / 2, code->m_Polygon.BBox().GetHeight() / 2 ); + bbox.Inflate( code->m_Polygon.BBox().GetWidth() / 2, + code->m_Polygon.BBox().GetHeight() / 2 ); + } break; } case GBR_SPOT_MACRO: { - // Update the shape drawings and the bounding box coordiantes: - code->GetMacro()->GetApertureMacroShape( this, m_Start ); - // now the bounding box is valid: - bbox = code->GetMacro()->GetBoundingBox(); + if( code ) + { + // Update the shape drawings and the bounding box coordiantes: + code->GetMacro()->GetApertureMacroShape( this, m_Start ); + // now the bounding box is valid: + bbox = code->GetMacro()->GetBoundingBox(); + } break; } diff --git a/gerbview/gerbview_painter.cpp b/gerbview/gerbview_painter.cpp index 8293a1c5ee..b2f91857c1 100644 --- a/gerbview/gerbview_painter.cpp +++ b/gerbview/gerbview_painter.cpp @@ -406,6 +406,9 @@ void GERBVIEW_PAINTER::drawFlashedShape( GERBER_DRAW_ITEM* aItem, bool aFilled ) wxASSERT_MSG( code, wxT( "drawFlashedShape: Item has no D_CODE!" ) ); + if( !code ) + return; + m_gal->SetIsFill( aFilled ); m_gal->SetIsStroke( !aFilled ); m_gal->SetLineWidth( m_gerbviewSettings.m_outlineWidth );