From 8648a074da7c875ae9ab4f1bec7b50efaf504291 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Sun, 6 Sep 2020 08:33:03 -0700 Subject: [PATCH] Ensure ZONEs use copy CTOR for super-class If we don't uniformly use the copy CTOR, we miss the additional properties held by the superclass. This also adds additional crash protection in GetMsgPanelInfo for zones although it should never be triggered Fixes https://gitlab.com/kicad/code/kicad/issues/5530 --- pcbnew/class_zone.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index 880e78f209..19ff5e95de 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -74,7 +74,7 @@ ZONE_CONTAINER::ZONE_CONTAINER( BOARD_ITEM_CONTAINER* aParent, bool aInModule ) ZONE_CONTAINER::ZONE_CONTAINER( const ZONE_CONTAINER& aZone ) - : BOARD_CONNECTED_ITEM( aZone.GetParent(), PCB_ZONE_AREA_T ), + : BOARD_CONNECTED_ITEM( aZone ), m_Poly( nullptr ), m_CornerSelection( nullptr ) { @@ -697,10 +697,14 @@ void ZONE_CONTAINER::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetActiveLayer() ) ) layer = pcbframe->GetActiveLayer(); #endif + auto layer_it = m_FilledPolysList.find( layer ); - if( !m_FilledPolysList.at( layer ).IsEmpty() ) + if( layer_it == m_FilledPolysList.end() ) + layer_it = m_FilledPolysList.begin(); + + if( layer_it != m_FilledPolysList.end() ) { - msg.Printf( wxT( "%d" ), m_FilledPolysList.at( layer ).TotalVertices() ); + msg.Printf( wxT( "%d" ), layer_it->second.TotalVertices() ); aList.emplace_back( MSG_PANEL_ITEM( _( "Corner Count" ), msg, BLUE ) ); } }