From 05cdf915d0fe8a5d57a8c5d71f7df9bb548df560 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Fri, 9 Sep 2022 17:19:29 -0700 Subject: [PATCH] Show ERC errors when any label only has 1 pin To be connected, the label must have at least two pins on a subgraph (or, in the case of a hierarchical label, two pins somewhere in its connection) Fixes https://gitlab.com/kicad/code/kicad/issues/7203 --- eeschema/connection_graph.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/eeschema/connection_graph.cpp b/eeschema/connection_graph.cpp index 921665600e..2998bb174b 100644 --- a/eeschema/connection_graph.cpp +++ b/eeschema/connection_graph.cpp @@ -3022,7 +3022,6 @@ bool CONNECTION_GRAPH::ercCheckLabels( const CONNECTION_SUBGRAPH* aSubgraph ) case SCH_PIN_T: case SCH_SHEET_PIN_T: - hasOtherConnections = true; pinCount++; break; @@ -3041,13 +3040,14 @@ bool CONNECTION_GRAPH::ercCheckLabels( const CONNECTION_SUBGRAPH* aSubgraph ) wxString name = EscapeString( text->GetShownText(), CTX_NETNAME ); + // Labels that have multiple pins connected are not dangling (may be used for naming segments) + // so leave them without errors here + if( pinCount > 1 ) + return true; + if( isGlobal ) { - // This will be set to true if the global is connected to a pin above, but we want to - // reset this to false so that globals get flagged if they only have a single instance - // connected to a single pin - hasOtherConnections = ( pinCount > 1 ); - + // Global labels are connected if there is another instance of their name in the circuit auto it = m_net_name_to_subgraphs_map.find( name ); if( it != m_net_name_to_subgraphs_map.end() ) @@ -3058,7 +3058,7 @@ bool CONNECTION_GRAPH::ercCheckLabels( const CONNECTION_SUBGRAPH* aSubgraph ) } else if( text->Type() == SCH_HIER_LABEL_T ) { - // For a hier label, check if the parent pin is connected + // Hierarchical labels are connected if their parents are connected if( aSubgraph->m_hier_parent && ( aSubgraph->m_hier_parent->m_strong_driver || aSubgraph->m_hier_parent->m_drivers.size() > 1) ) @@ -3080,7 +3080,7 @@ bool CONNECTION_GRAPH::ercCheckLabels( const CONNECTION_SUBGRAPH* aSubgraph ) if( neighbor == aSubgraph ) continue; - if( hasPins( neighbor ) ) + if( hasPins( neighbor ) && ++pinCount > 1 ) { hasOtherConnections = true; break;