Don't pick a name with a longer path to override with

Only triggered on some platforms because of compiler-dependent
unordered_set iteration

Fixes https://gitlab.com/kicad/code/kicad/-/issues/7169
This commit is contained in:
Jon Evans 2021-01-18 20:23:31 -05:00
parent eb80ac464a
commit 6cd4fcf30c
1 changed files with 9 additions and 4 deletions

View File

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