From 4efed8a4dd4d2518da942686f031f2abcb99f0a2 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Wed, 1 May 2019 20:15:08 -0400 Subject: [PATCH] Ensure global labels get flagged as lonely in all circumstances Fixes: lp:1827214 * https://bugs.launchpad.net/kicad/+bug/1827214 --- eeschema/connection_graph.cpp | 37 ++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/eeschema/connection_graph.cpp b/eeschema/connection_graph.cpp index c50f3a3e83..8d4150e0c2 100644 --- a/eeschema/connection_graph.cpp +++ b/eeschema/connection_graph.cpp @@ -2077,32 +2077,37 @@ bool CONNECTION_GRAPH::ercCheckLabels( const CONNECTION_SUBGRAPH* aSubgraph, } } - bool is_global = text && ( text->Type() == SCH_GLOBAL_LABEL_T ); + if( !text ) + return true; + + bool is_global = text->Type() == SCH_GLOBAL_LABEL_T; // Global label check can be disabled independently if( !aCheckGlobalLabels && is_global ) return true; - if( text ) + wxString name = text->GetShownText(); + + if( is_global) { - wxString name = text->GetShownText(); + // 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 + has_other_connections = false; - if( is_global) - { - if( m_net_name_to_subgraphs_map.count( name ) - && m_net_name_to_subgraphs_map.at( name ).size() > 1 ) - has_other_connections = true; - } - else - { - auto pair = std::make_pair( aSubgraph->m_sheet, name ); + if( m_net_name_to_subgraphs_map.count( name ) + && m_net_name_to_subgraphs_map.at( name ).size() > 1 ) + has_other_connections = true; + } + else + { + auto pair = std::make_pair( aSubgraph->m_sheet, name ); - if( m_local_label_cache.count( pair ) && m_local_label_cache.at( pair ).size() > 1 ) - has_other_connections = true; - } + if( m_local_label_cache.count( pair ) && m_local_label_cache.at( pair ).size() > 1 ) + has_other_connections = true; } - if( text && !has_other_connections ) + if( !has_other_connections ) { if( aCreateMarkers ) {