diff --git a/eeschema/connection_graph.cpp b/eeschema/connection_graph.cpp index 3cf80783c8..fff5591f1e 100644 --- a/eeschema/connection_graph.cpp +++ b/eeschema/connection_graph.cpp @@ -1834,23 +1834,28 @@ void CONNECTION_GRAPH::propagateToNeighbors( CONNECTION_SUBGRAPH* aSubgraph ) { for( CONNECTION_SUBGRAPH* subgraph : visited ) { + if( subgraph == original ) + continue; + CONNECTION_SUBGRAPH::PRIORITY priority = CONNECTION_SUBGRAPH::GetDriverPriority( subgraph->m_driver ); bool candidateStrong = ( priority >= CONNECTION_SUBGRAPH::PRIORITY::HIER_LABEL ); wxString candidateName = subgraph->m_driver_connection->Name(); + bool shorterPath = subgraph->m_sheet.size() < original->m_sheet.size(); + bool asGoodPath = subgraph->m_sheet.size() <= original->m_sheet.size(); // Pick a better driving subgraph if it: // a) has a power pin or global driver // b) is a strong driver and we're a weak driver // c) meets or exceeds our priority, is a strong driver, and has a shorter path - // d) is weak, we're week, and is alphabetically lower + // d) matches our strength and is at least as short, and is alphabetically lower if( ( priority >= CONNECTION_SUBGRAPH::PRIORITY::POWER_PIN ) || ( !originalStrong && candidateStrong ) || - ( priority >= highest && candidateStrong && - subgraph->m_sheet.size() < original->m_sheet.size() ) || - ( ( originalStrong == candidateStrong ) && candidateName < originalName ) ) + ( priority >= highest && candidateStrong && shorterPath ) || + ( ( originalStrong == candidateStrong ) && asGoodPath && + ( candidateName < originalName ) ) ) { original = subgraph; highest = priority;