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

(cherry picked from commit 05cdf915d0)
This commit is contained in:
Seth Hillbrand 2022-09-09 17:19:29 -07:00
parent e5fa18c9b1
commit f3ff9ddd31
1 changed files with 8 additions and 8 deletions

View File

@ -2921,7 +2921,6 @@ bool CONNECTION_GRAPH::ercCheckLabels( const CONNECTION_SUBGRAPH* aSubgraph )
case SCH_PIN_T:
case SCH_SHEET_PIN_T:
hasOtherConnections = true;
pinCount++;
break;
@ -2940,13 +2939,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() )
@ -2957,7 +2957,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) )
@ -2979,7 +2979,7 @@ bool CONNECTION_GRAPH::ercCheckLabels( const CONNECTION_SUBGRAPH* aSubgraph )
if( neighbor == aSubgraph )
continue;
if( hasPins( neighbor ) )
if( hasPins( neighbor ) && ++pinCount > 1 )
{
hasOtherConnections = true;
break;