From d6c3f4d19073eacc37211b1eff78fba67899afc0 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Thu, 5 Oct 2023 08:39:56 -0700 Subject: [PATCH] Protect against subgraph loops Optimize the subgraph processing to avoid repeated loops when multiple items belong to the same subgraph. (cherry picked from commit 75de21314cc0b0d1223f119d1243f88b54f6675f) --- eeschema/connection_graph.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/eeschema/connection_graph.cpp b/eeschema/connection_graph.cpp index 2e4da88c94..469f5a2708 100644 --- a/eeschema/connection_graph.cpp +++ b/eeschema/connection_graph.cpp @@ -240,7 +240,11 @@ void CONNECTION_SUBGRAPH::getAllConnectedItems( std::setm_absorbed_by; } - aSubgraphs.insert( sg ); + // If we are unable to insert the subgraph into the set, then we have already + // visited it and don't need to add it again. + if( aSubgraphs.insert( sg ).second == false ) + return; + aSubgraphs.insert( sg->m_absorbed_subgraphs.begin(), sg->m_absorbed_subgraphs.end() ); for( SCH_ITEM* item : sg->m_items )