From 40a3b4a533f3cfa7c927d7f102950f13555578b9 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Tue, 18 Sep 2018 15:18:55 +0200 Subject: [PATCH] GERBVIEW_RENDER_SETTINGS: verify item type Not all items displayed by Gerbview are GERBER_DRAW_ITEMs (e.g. WORKSHEET_VIEWITEM), so appropriate checks have been added. --- gerbview/gerbview_painter.cpp | 37 ++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/gerbview/gerbview_painter.cpp b/gerbview/gerbview_painter.cpp index 7c313fe82f..d3ce818a0f 100644 --- a/gerbview/gerbview_painter.cpp +++ b/gerbview/gerbview_painter.cpp @@ -99,37 +99,38 @@ void GERBVIEW_RENDER_SETTINGS::LoadDisplayOptions( const GBR_DISPLAY_OPTIONS* aO const COLOR4D& GERBVIEW_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) const { - const GERBER_DRAW_ITEM* item = static_cast( aItem ); + const EDA_ITEM* item = static_cast( aItem ); static const COLOR4D transparent = COLOR4D( 0, 0, 0, 0 ); + const GERBER_DRAW_ITEM* gbrItem = nullptr; + + if( item && item->Type() == GERBER_DRAW_ITEM_T ) + gbrItem = static_cast( item ); // All DCODE layers stored under a single color setting if( IsDCodeLayer( aLayer ) ) return m_layerColors[ LAYER_DCODES ]; - if( item ) - { - if( item->IsSelected() ) - return m_layerColorsSel[aLayer]; + if( item && item->IsSelected() ) + return m_layerColorsSel[aLayer]; - if( item->GetLayerPolarity() ) - { - if( m_showNegativeItems ) - return m_layerColors[LAYER_NEGATIVE_OBJECTS]; - else - return transparent; - } + if( gbrItem && gbrItem->GetLayerPolarity() ) + { + if( m_showNegativeItems ) + return m_layerColors[LAYER_NEGATIVE_OBJECTS]; + else + return transparent; } - if( !m_netHighlightString.IsEmpty() && item && - m_netHighlightString == item->GetNetAttributes().m_Netname ) + if( !m_netHighlightString.IsEmpty() && gbrItem && + m_netHighlightString == gbrItem->GetNetAttributes().m_Netname ) return m_layerColorsHi[aLayer]; - if( !m_componentHighlightString.IsEmpty() && item && - m_componentHighlightString == item->GetNetAttributes().m_Cmpref ) + if( !m_componentHighlightString.IsEmpty() && gbrItem && + m_componentHighlightString == gbrItem->GetNetAttributes().m_Cmpref ) return m_layerColorsHi[aLayer]; - if( !m_attributeHighlightString.IsEmpty() && item && item->GetDcodeDescr() && - m_attributeHighlightString == item->GetDcodeDescr()->m_AperFunction ) + if( !m_attributeHighlightString.IsEmpty() && gbrItem && gbrItem->GetDcodeDescr() && + m_attributeHighlightString == gbrItem->GetDcodeDescr()->m_AperFunction ) return m_layerColorsHi[aLayer]; // Return grayish color for non-highlighted layers in the high contrast mode