From 8b87dc7e0fca43aec65a55d72a80411645a5a2db Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Fri, 29 Nov 2019 21:10:16 -0500 Subject: [PATCH] A slightly better ERC check for hierarchical labels Fixes: lp:1839822 * https://bugs.launchpad.net/kicad/+bug/1839822 --- eeschema/connection_graph.cpp | 14 ++++++++++++++ eeschema/connection_graph.h | 5 ++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/eeschema/connection_graph.cpp b/eeschema/connection_graph.cpp index 0003f8b6ff..5a31b06994 100644 --- a/eeschema/connection_graph.cpp +++ b/eeschema/connection_graph.cpp @@ -1481,6 +1481,8 @@ void CONNECTION_GRAPH::propagateToNeighbors( CONNECTION_SUBGRAPH* aSubgraph ) wxLogTrace( "CONN", "%lu: found child %lu (%s)", aParent->m_code, candidate->m_code, candidate->m_driver_connection->Name() ); + candidate->m_hier_parent = aParent; + search_list.push_back( candidate ); break; } @@ -2269,6 +2271,18 @@ bool CONNECTION_GRAPH::ercCheckLabels( const CONNECTION_SUBGRAPH* aSubgraph, && m_net_name_to_subgraphs_map.at( name ).size() > 1 ) has_other_connections = true; } + else if (text->Type() == SCH_HIER_LABEL_T) + { + // For a hier label, check if the parent pin is connected + if (aSubgraph->m_hier_parent && + (aSubgraph->m_hier_parent->m_strong_driver || + aSubgraph->m_hier_parent->m_drivers.size() > 1)) + { + // For now, a simple check: if there is more than one driver, the parent is probably + // connected elsewhere (because at least one driver will be the hier pin itself) + has_other_connections = true; + } + } else { auto pair = std::make_pair( aSubgraph->m_sheet, name ); diff --git a/eeschema/connection_graph.h b/eeschema/connection_graph.h index 3e616b1ad6..ae8eead68e 100644 --- a/eeschema/connection_graph.h +++ b/eeschema/connection_graph.h @@ -72,7 +72,7 @@ public: m_dirty( false ), m_absorbed( false ), m_absorbed_by( nullptr ), m_code( -1 ), m_multiple_drivers( false ), m_strong_driver( false ), m_local_driver( false ), m_no_connect( nullptr ), m_bus_entry( nullptr ), m_driver( nullptr ), m_frame( aFrame ), - m_driver_connection( nullptr ) + m_driver_connection( nullptr ), m_hier_parent( nullptr ) {} /** * Determines which potential driver should drive the subgraph. @@ -188,6 +188,9 @@ public: // Cache for lookup of any hierarchical ports on this subgraph (for referring up) std::vector m_hier_ports; + + // If not null, this indicates the subgraph on a higher level sheet that is linked to this one + CONNECTION_SUBGRAPH* m_hier_parent; };