From c92181621e2e51dc8aae1bd9f4483bb3301ffaa5 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Wed, 6 May 2020 18:26:56 -0400 Subject: [PATCH] Use strong check for bus label when netlisting Fixes #4318 --- eeschema/sch_connection.cpp | 11 +++++++++-- eeschema/sch_connection.h | 9 +++++++++ eeschema/sch_screen.cpp | 8 ++++---- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/eeschema/sch_connection.cpp b/eeschema/sch_connection.cpp index 0591b34f53..e7589a2b0e 100644 --- a/eeschema/sch_connection.cpp +++ b/eeschema/sch_connection.cpp @@ -400,9 +400,16 @@ void SCH_CONNECTION::AppendDebugInfoToMsgPanel( MSG_PANEL_ITEMS& aList ) const bool SCH_CONNECTION::IsBusLabel( const wxString& aLabel ) { - //return IsBusVectorLabel( aLabel ) || IsBusGroupLabel( aLabel ); + return IsBusVectorLabel( aLabel ) || IsBusGroupLabel( aLabel ); +} + + +bool SCH_CONNECTION::MightBeBusLabel( const wxString& aLabel ) +{ // Weak heuristic for performance reasons. Stronger test will be used for connectivity - return aLabel.Contains( wxT( "[" ) ) || aLabel.Contains( wxT( "{" ) ); + wxString label = UnescapeString( aLabel ); + + return label.Contains( wxT( "[" ) ) || label.Contains( wxT( "{" ) ); } diff --git a/eeschema/sch_connection.h b/eeschema/sch_connection.h index 7558c490cc..93bf28d8ac 100644 --- a/eeschema/sch_connection.h +++ b/eeschema/sch_connection.h @@ -303,6 +303,15 @@ public: */ static bool IsBusLabel( const wxString& aLabel ); + /** + * Test if \a aLabel looks like a bus notation. + * This check is much less expensive than IsBusLabel. + * + * @param aLabel A wxString object containing the label to test. + * @return true if text might be a bus label + */ + static bool MightBeBusLabel( const wxString& aLabel ); + /** * Test if \a aLabel has a bus vector notation (simple bus, e.g. A[7..0]) * diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index 3aebbf212f..45bf509881 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -523,12 +523,12 @@ bool SCH_SCREEN::IsTerminalPoint( const wxPoint& aPosition, int aLayer ) label = GetSheetLabel( aPosition ); - if( label && conn.IsBusLabel( label->GetText() ) && label->IsConnected( aPosition ) ) + if( label && conn.MightBeBusLabel( label->GetText() ) && label->IsConnected( aPosition ) ) return true; text = GetLabel( aPosition ); - if( text && conn.IsBusLabel( text->GetText() ) && text->IsConnected( aPosition ) + if( text && conn.MightBeBusLabel( text->GetText() ) && text->IsConnected( aPosition ) && (text->Type() != SCH_LABEL_T) ) return true; @@ -559,12 +559,12 @@ bool SCH_SCREEN::IsTerminalPoint( const wxPoint& aPosition, int aLayer ) text = GetLabel( aPosition ); - if( text && text->IsConnected( aPosition ) && !conn.IsBusLabel( text->GetText() ) ) + if( text && text->IsConnected( aPosition ) && !conn.MightBeBusLabel( text->GetText() ) ) return true; label = GetSheetLabel( aPosition ); - if( label && label->IsConnected( aPosition ) && !conn.IsBusLabel( label->GetText() ) ) + if( label && label->IsConnected( aPosition ) && !conn.MightBeBusLabel( label->GetText() ) ) return true; break;