From 3233bedc7a932e8f356ce7be129563a2f62bc8df Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Thu, 25 Apr 2019 16:04:01 -0400 Subject: [PATCH] Ensure pin map pointers are valid after pin vector is filled --- eeschema/sch_component.cpp | 8 +++----- eeschema/sch_item_struct.cpp | 3 +++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index 933d6214a0..2bf41cadd1 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -445,13 +445,11 @@ void SCH_COMPONENT::UpdatePins( SCH_SHEET_PATH* aSheet ) m_pins.emplace_back( SCH_PIN( libPin, this ) ); } - m_pinMap[ libPin ] = &m_pins[ i ]; - - if( aSheet ) - m_pins[ i ].InitializeConnection( *aSheet ); - ++i; } + + for( SCH_PIN& pin : m_pins ) + m_pinMap[ pin.GetLibPin() ] = &pin; } } diff --git a/eeschema/sch_item_struct.cpp b/eeschema/sch_item_struct.cpp index 399889d34d..8a83db6973 100644 --- a/eeschema/sch_item_struct.cpp +++ b/eeschema/sch_item_struct.cpp @@ -68,6 +68,9 @@ SCH_ITEM::~SCH_ITEM() // are owned by the sheet object container. if( !m_connections.empty() ) m_connections.clear(); + + for( const auto& it : m_connection_map ) + delete it.second; }