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
This commit is contained in:
Jeff Young 2023-04-04 11:33:07 +01:00
parent b3e2cf218f
commit 7e5cd01079
3 changed files with 2 additions and 7 deletions

View File

@ -1770,7 +1770,7 @@ int CONNECTION_GRAPH::assignNewNetCode( SCH_CONNECTION& aConnection )
void CONNECTION_GRAPH::assignNetCodesToBus( SCH_CONNECTION* aConnection )
{
std::vector< std::shared_ptr<SCH_CONNECTION>>& connections_to_check( aConnection->Members() );
std::vector<std::shared_ptr<SCH_CONNECTION>> connections_to_check( aConnection->Members() );
for( unsigned i = 0; i < connections_to_check.size(); i++ )
{

View File

@ -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;

View File

@ -903,7 +903,7 @@ void SCH_LINE::Plot( PLOTTER* aPlotter, bool aBackground ) const
{
if( SCH_CONNECTION* connection = Connection() )
{
for( std::shared_ptr<SCH_CONNECTION>& member : connection->Members() )
for( const std::shared_ptr<SCH_CONNECTION>& member : connection->Members() )
properties.emplace_back( wxT( "!" ) + member->Name() );
}