From dce2247925d475217ae590b3d2ec6ba711c18197 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 4 Apr 2023 11:33:07 +0100 Subject: [PATCH] Improve scoping control of connetion members. (The real bug here is that CONNECTION_GRAPH::assignNetCodesToBus() was growing the bus aliases members list because it used a non-const reference to it as a local storage list. The const scoping of it will prevent this type of error in future.) Fixes https://gitlab.com/kicad/code/kicad/issues/14269 --- eeschema/connection_graph.cpp | 2 +- eeschema/sch_connection.h | 5 ----- eeschema/sch_line.cpp | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/eeschema/connection_graph.cpp b/eeschema/connection_graph.cpp index c26724995f..ee0b48064f 100644 --- a/eeschema/connection_graph.cpp +++ b/eeschema/connection_graph.cpp @@ -1759,7 +1759,7 @@ int CONNECTION_GRAPH::assignNewNetCode( SCH_CONNECTION& aConnection ) void CONNECTION_GRAPH::assignNetCodesToBus( SCH_CONNECTION* aConnection ) { - std::vector< std::shared_ptr>& connections_to_check( aConnection->Members() ); + std::vector> connections_to_check( aConnection->Members() ); for( unsigned i = 0; i < connections_to_check.size(); i++ ) { diff --git a/eeschema/sch_connection.h b/eeschema/sch_connection.h index c846fc79e8..3ec40c746a 100644 --- a/eeschema/sch_connection.h +++ b/eeschema/sch_connection.h @@ -185,11 +185,6 @@ public: wxString VectorPrefix() const { return m_vector_prefix; } - std::vector< std::shared_ptr< SCH_CONNECTION > >& Members() - { - return m_members; - } - const std::vector< std::shared_ptr< SCH_CONNECTION > >& Members() const { return m_members; diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index 99bae09c1a..e13a590389 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -872,7 +872,7 @@ void SCH_LINE::Plot( PLOTTER* aPlotter, bool aBackground ) const { if( SCH_CONNECTION* connection = Connection() ) { - for( std::shared_ptr& member : connection->Members() ) + for( const std::shared_ptr& member : connection->Members() ) properties.emplace_back( wxT( "!" ) + member->Name() ); }