From df16ea25a81c18f381a7d01f129f9bbe3e87381c Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Mon, 25 May 2020 17:03:49 -0400 Subject: [PATCH] Properly send cross-probe for nested buses Fixes https://gitlab.com/kicad/code/kicad/-/issues/4541 --- eeschema/cross-probing.cpp | 10 ++++++---- eeschema/sch_connection.cpp | 12 ++++++++++++ eeschema/sch_connection.h | 2 ++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/eeschema/cross-probing.cpp b/eeschema/cross-probing.cpp index 2bc4e80f4b..04b71796de 100644 --- a/eeschema/cross-probing.cpp +++ b/eeschema/cross-probing.cpp @@ -384,9 +384,11 @@ void SCH_EDIT_FRAME::SetCrossProbeConnection( const SCH_CONNECTION* aConnection if( aConnection->Members().empty() ) return; - wxString nets = aConnection->Members()[0]->Name(); + auto all_members = aConnection->AllMembers(); - if( aConnection->Members().size() == 1 ) + wxString nets = all_members[0]->Name(); + + if( all_members.size() == 1 ) { SendCrossProbeNetName( nets ); return; @@ -396,8 +398,8 @@ void SCH_EDIT_FRAME::SetCrossProbeConnection( const SCH_CONNECTION* aConnection // included as part of the netlist sent from eeschema to pcbnew (and thus pcbnew can // natively keep track of bus membership) - for( size_t i = 1; i < aConnection->Members().size(); i++ ) - nets << "," << aConnection->Members()[i]->Name(); + for( size_t i = 1; i < all_members.size(); i++ ) + nets << "," << all_members[i]->Name(); std::string packet = StrPrintf( "$NETS: \"%s\"", TO_UTF8( nets ) ); diff --git a/eeschema/sch_connection.cpp b/eeschema/sch_connection.cpp index 3d5c4f3a7e..42f54cde9f 100644 --- a/eeschema/sch_connection.cpp +++ b/eeschema/sch_connection.cpp @@ -643,6 +643,18 @@ bool SCH_CONNECTION::ParseBusGroup( wxString aGroup, wxString* aName, } +const std::vector< std::shared_ptr< SCH_CONNECTION > > SCH_CONNECTION::AllMembers() const +{ + std::vector< std::shared_ptr< SCH_CONNECTION > > ret( m_members ); + + for( const auto& member : m_members ) + if( member->IsBus() ) + ret.insert( ret.end(), member->Members().begin(), member->Members().end() ); + + return ret; +} + + wxString SCH_CONNECTION::PrintBusForUI( const wxString& aGroup ) { size_t groupLen = aGroup.length(); diff --git a/eeschema/sch_connection.h b/eeschema/sch_connection.h index 3d75c1a8b9..3e28ec52ea 100644 --- a/eeschema/sch_connection.h +++ b/eeschema/sch_connection.h @@ -258,6 +258,8 @@ public: return m_members; } + const std::vector< std::shared_ptr< SCH_CONNECTION > > AllMembers() const; + static wxString PrintBusForUI( const wxString& aString ); /**