Clean up nets from items when deleting in the inspector
Fixes https://gitlab.com/kicad/code/kicad/-/issues/8162
This commit is contained in:
parent
311cde0984
commit
36ef198610
|
@ -671,7 +671,28 @@ void BOARD::Remove( BOARD_ITEM* aBoardItem, REMOVE_MODE aRemoveMode )
|
||||||
{
|
{
|
||||||
case PCB_NETINFO_T:
|
case PCB_NETINFO_T:
|
||||||
{
|
{
|
||||||
NETINFO_ITEM* item = (NETINFO_ITEM*) aBoardItem;
|
NETINFO_ITEM* item = static_cast<NETINFO_ITEM*>( aBoardItem );
|
||||||
|
NETINFO_ITEM* unconnected = m_NetInfo.GetNetItem( NETINFO_LIST::UNCONNECTED );
|
||||||
|
int removedCode = item->GetNetCode();
|
||||||
|
|
||||||
|
for( FOOTPRINT* fp : m_footprints )
|
||||||
|
{
|
||||||
|
for( PAD* pad : fp->Pads() )
|
||||||
|
{
|
||||||
|
if( pad->GetNetCode() == removedCode )
|
||||||
|
pad->SetNet( unconnected );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for( ZONE* zone : m_zones )
|
||||||
|
{
|
||||||
|
if( zone->GetNetCode() == removedCode )
|
||||||
|
zone->SetNet( unconnected );
|
||||||
|
}
|
||||||
|
|
||||||
|
for( TRACK* track : TracksInNet( removedCode ) )
|
||||||
|
track->SetNet( unconnected );
|
||||||
|
|
||||||
m_NetInfo.RemoveNet( item );
|
m_NetInfo.RemoveNet( item );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1928,6 +1928,19 @@ void DIALOG_NET_INSPECTOR::onDeleteNet( wxCommandEvent& aEvent )
|
||||||
|| IsOK( this, wxString::Format( _( "Net '%s' is in use. Delete anyway?" ),
|
|| IsOK( this, wxString::Format( _( "Net '%s' is in use. Delete anyway?" ),
|
||||||
i->GetNetName() ) ) )
|
i->GetNetName() ) ) )
|
||||||
{
|
{
|
||||||
|
// This is a bit hacky, but it will do for now, since this is the only path
|
||||||
|
// outside the netlist updater where you can remove a net from a BOARD.
|
||||||
|
int removedCode = i->GetNetCode();
|
||||||
|
|
||||||
|
m_frame->GetCanvas()->GetView()->UpdateAllItemsConditionally( KIGFX::REPAINT,
|
||||||
|
[removedCode]( KIGFX::VIEW_ITEM* aItem ) -> bool
|
||||||
|
{
|
||||||
|
if( auto bci = dynamic_cast<BOARD_CONNECTED_ITEM*>( aItem ) )
|
||||||
|
return bci->GetNetCode() == removedCode;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
} );
|
||||||
|
|
||||||
m_brd->Remove( i->GetNet() );
|
m_brd->Remove( i->GetNet() );
|
||||||
m_frame->OnModify();
|
m_frame->OnModify();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue