From 4cdf75dc72fac2cbc707d89d84486323b64cc3f8 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Wed, 3 May 2023 13:35:51 -0700 Subject: [PATCH] Remove matching parents/neighbors in subgraphs This ensures that when bus elements or labels matching bus elements are removed that the stale neighbor/parent references are similarly removed --- eeschema/connection_graph.cpp | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/eeschema/connection_graph.cpp b/eeschema/connection_graph.cpp index ebd5d98c27..899b6a4d45 100644 --- a/eeschema/connection_graph.cpp +++ b/eeschema/connection_graph.cpp @@ -711,6 +711,44 @@ void CONNECTION_GRAPH::removeSubgraphs( std::set& aSubgrap for( CONNECTION_SUBGRAPH* sg : aSubgraphs ) { + for( auto it : sg->m_bus_neighbors ) + { + for( CONNECTION_SUBGRAPH* neighbor : it.second ) + { + auto& parents = neighbor->m_bus_parents[it.first]; + + for( auto test = parents.begin(); test != parents.end(); ) + { + if( *test == sg ) + test = parents.erase( test ); + else + ++test; + } + + if( parents.empty() ) + neighbor->m_bus_parents.erase( it.first ); + } + } + + for( auto it : sg->m_bus_parents ) + { + for( CONNECTION_SUBGRAPH* parent : it.second ) + { + auto& neighbors = parent->m_bus_neighbors[it.first]; + + for( auto test = neighbors.begin(); test != neighbors.end(); ) + { + if( *test == sg ) + test = neighbors.erase( test ); + else + ++test; + } + + if( neighbors.empty() ) + parent->m_bus_neighbors.erase( it.first ); + } + } + { auto it = std::lower_bound( m_driver_subgraphs.begin(), m_driver_subgraphs.end(), sg );