From 3d852372ca3ec425cb2c0a39b9984da26eae931c Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 20 Dec 2020 15:08:43 +0000 Subject: [PATCH] Handle nested unescaping (for buses in particular). Also adds a few missing unescape() calls when showing netnames to the user. Fixes https://gitlab.com/kicad/code/kicad/issues/6400 --- common/string.cpp | 10 ++++++++-- eeschema/connection_graph.cpp | 23 ++++++++++++++--------- eeschema/sch_text.cpp | 3 +-- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/common/string.cpp b/common/string.cpp index f0e9b719a1..7fd7ccd14f 100644 --- a/common/string.cpp +++ b/common/string.cpp @@ -170,10 +170,16 @@ wxString UnescapeString( const wxString& aSource ) else if( aSource[i] == '{' ) { wxString token; + int depth = 1; for( i = i + 1; i < sourceLen; ++i ) { - if( aSource[i] == '}' ) + if( aSource[i] == '{' ) + depth++; + else if( aSource[i] == '}' ) + depth--; + + if( depth <= 0 ) break; else token.append( aSource[i] ); @@ -194,7 +200,7 @@ wxString UnescapeString( const wxString& aSource ) else if( token == wxS( "brace" ) ) newbuf.append( wxS( "{" ) ); else { - newbuf.append( "{" + token + "}" ); + newbuf.append( "{" + UnescapeString( token ) + "}" ); } } else diff --git a/eeschema/connection_graph.cpp b/eeschema/connection_graph.cpp index e7782b434b..b3012d4ef0 100644 --- a/eeschema/connection_graph.cpp +++ b/eeschema/connection_graph.cpp @@ -2320,13 +2320,15 @@ bool CONNECTION_GRAPH::ercCheckBusToBusEntryConflicts( const CONNECTION_SUBGRAPH // In some cases, the connection list (SCH_CONNECTION*) can be null. // Skip null connections. - if( bus_entry->Connection( &sheet ) && bus_wire->Type() == SCH_LINE_T - && bus_wire->Connection( &sheet ) ) + if( bus_entry->Connection( &sheet ) + && bus_wire->Type() == SCH_LINE_T + && bus_wire->Connection( &sheet ) ) { - conflict = true; + conflict = true; // Assume a conflict; we'll reset if we find it's OK + bus_name = bus_wire->Connection( &sheet )->Name( true ); - auto test_name = bus_entry->Connection( &sheet )->Name( true ); + wxString test_name = bus_entry->Connection( &sheet )->Name( true ); for( const auto& member : bus_wire->Connection( &sheet )->Members() ) { @@ -2354,10 +2356,11 @@ bool CONNECTION_GRAPH::ercCheckBusToBusEntryConflicts( const CONNECTION_SUBGRAPH if( conflict ) { + wxString netName = aSubgraph->m_driver_connection->Name( true ); wxString msg = wxString::Format( _( "Net %s is graphically connected to bus %s but is not a" " member of that bus" ), - aSubgraph->m_driver_connection->Name( true ), - bus_name ); + UnescapeString( netName ), + UnescapeString( bus_name ) ); std::shared_ptr ercItem = ERC_ITEM::Create( ERCE_BUS_ENTRY_CONFLICT ); ercItem->SetItems( bus_entry, bus_wire ); ercItem->SetErrorMessage( msg ); @@ -2726,11 +2729,13 @@ int CONNECTION_GRAPH::ercCheckHierSheets() for( const std::pair& unmatched : pins ) { + wxString msg = wxString::Format( _( "Sheet pin %s has no matching hierarchical " + "label inside the sheet" ), + UnescapeString( unmatched.first ) ); + std::shared_ptr ercItem = ERC_ITEM::Create( ERCE_HIERACHICAL_LABEL ); ercItem->SetItems( unmatched.second ); - ercItem->SetErrorMessage( wxString::Format( - _( "Sheet port %s has no matching hierarchical label inside the sheet" ), - unmatched.first ) ); + ercItem->SetErrorMessage( msg ); SCH_MARKER* marker = new SCH_MARKER( ercItem, unmatched.second->GetPosition() ); sheet.LastScreen()->Append( marker ); diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 592d4d769b..129ba5a6d1 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -552,8 +552,7 @@ wxString SCH_TEXT::GetShownText( int aDepth ) const if( processTextVars ) { - wxCHECK_MSG( Schematic(), wxEmptyString, - "No parent SCHEMATIC set for SCH_TEXT!" ); + wxCHECK_MSG( Schematic(), wxEmptyString, "No parent SCHEMATIC set for SCH_TEXT!" ); PROJECT* project = nullptr;