Make sure nets get reassigned when name is changed.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17025

(cherry picked from commit f4a3613561)
This commit is contained in:
Jeff Young 2024-02-20 17:33:35 +00:00 committed by Roberto Fernandez Bautista
parent 5c026db27a
commit 7b17646b71
1 changed files with 19 additions and 19 deletions

View File

@ -2166,34 +2166,34 @@ void DIALOG_NET_INSPECTOR::onRenameNet( wxCommandEvent& aEvent )
} }
} }
// the changed name might require re-grouping. remove and re-insert for( BOARD_CONNECTED_ITEM* boardItem : m_frame->GetBoard()->AllConnectedItems() )
// is easier. {
if( boardItem->GetNet() == net )
boardItem->SetFlags( CANDIDATE );
else
boardItem->ClearFlags( CANDIDATE );
}
// the changed name might require re-grouping. remove/re-insert is easier.
auto removed_item = m_data_model->deleteItem( m_data_model->findItem( net ) ); auto removed_item = m_data_model->deleteItem( m_data_model->findItem( net ) );
m_brd->Remove( net ); m_brd->Remove( net );
net->SetNetname( fullNetName ); net->SetNetname( fullNetName );
m_brd->Add( net ); m_brd->Add( net );
m_frame->OnModify();
if( netFilterMatches( net ) ) for( BOARD_CONNECTED_ITEM* boardItem : m_frame->GetBoard()->AllConnectedItems() )
{ {
std::unique_ptr<LIST_ITEM> new_item = std::make_unique<LIST_ITEM>( net ); if( boardItem->GetFlags() & CANDIDATE )
new_item->SetPadCount( removed_item->GetPadCount() ); boardItem->SetNet( net );
new_item->SetViaCount( removed_item->GetViaCount() );
for( int ii = 0; ii < MAX_CU_LAYERS; ++ii )
new_item->SetLayerWireLength( removed_item->GetLayerWireLength( ii ), ii );
new_item->SetChipWireLength( removed_item->GetChipWireLength() );
std::optional<LIST_ITEM_ITER> added_row = m_data_model->addItem( std::move( new_item ) );
wxDataViewItemArray new_sel;
new_sel.Add( wxDataViewItem( &***added_row ) );
m_netsList->SetSelections( new_sel );
onSelChanged();
} }
buildNetsList();
if( std::optional<LIST_ITEM_ITER> r = m_data_model->findItem( net ) )
m_netsList->Select( wxDataViewItem( r.value()->get() ) );
m_frame->OnModify();
// Currently only tracks and pads have netname annotations and need to be redrawn, // Currently only tracks and pads have netname annotations and need to be redrawn,
// but zones are likely to follow. Since we don't have a way to ask what is current, // but zones are likely to follow. Since we don't have a way to ask what is current,
// just refresh all items. // just refresh all items.