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 );