Don't double-remove nets when netcodes are reused
Fixes https://gitlab.com/kicad/code/kicad/-/issues/8206
This commit is contained in:
parent
55c1d814f9
commit
ce01a28aad
|
@ -673,25 +673,27 @@ void BOARD::Remove( BOARD_ITEM* aBoardItem, REMOVE_MODE aRemoveMode )
|
||||||
{
|
{
|
||||||
NETINFO_ITEM* item = static_cast<NETINFO_ITEM*>( aBoardItem );
|
NETINFO_ITEM* item = static_cast<NETINFO_ITEM*>( aBoardItem );
|
||||||
NETINFO_ITEM* unconnected = m_NetInfo.GetNetItem( NETINFO_LIST::UNCONNECTED );
|
NETINFO_ITEM* unconnected = m_NetInfo.GetNetItem( NETINFO_LIST::UNCONNECTED );
|
||||||
int removedCode = item->GetNetCode();
|
|
||||||
|
|
||||||
for( FOOTPRINT* fp : m_footprints )
|
for( FOOTPRINT* fp : m_footprints )
|
||||||
{
|
{
|
||||||
for( PAD* pad : fp->Pads() )
|
for( PAD* pad : fp->Pads() )
|
||||||
{
|
{
|
||||||
if( pad->GetNetCode() == removedCode )
|
if( pad->GetNet() == item )
|
||||||
pad->SetNet( unconnected );
|
pad->SetNet( unconnected );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for( ZONE* zone : m_zones )
|
for( ZONE* zone : m_zones )
|
||||||
{
|
{
|
||||||
if( zone->GetNetCode() == removedCode )
|
if( zone->GetNet() == item )
|
||||||
zone->SetNet( unconnected );
|
zone->SetNet( unconnected );
|
||||||
}
|
}
|
||||||
|
|
||||||
for( TRACK* track : TracksInNet( removedCode ) )
|
for( TRACK* track : m_tracks )
|
||||||
track->SetNet( unconnected );
|
{
|
||||||
|
if( track->GetNet() == item )
|
||||||
|
track->SetNet( unconnected );
|
||||||
|
}
|
||||||
|
|
||||||
m_NetInfo.RemoveNet( item );
|
m_NetInfo.RemoveNet( item );
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -83,10 +83,13 @@ NETINFO_ITEM* NETINFO_LIST::GetNetItem( const wxString& aNetName ) const
|
||||||
|
|
||||||
void NETINFO_LIST::RemoveNet( NETINFO_ITEM* aNet )
|
void NETINFO_LIST::RemoveNet( NETINFO_ITEM* aNet )
|
||||||
{
|
{
|
||||||
|
bool removed = false;
|
||||||
|
|
||||||
for( NETCODES_MAP::iterator i = m_netCodes.begin(); i != m_netCodes.end(); ++i )
|
for( NETCODES_MAP::iterator i = m_netCodes.begin(); i != m_netCodes.end(); ++i )
|
||||||
{
|
{
|
||||||
if ( i->second == aNet )
|
if ( i->second == aNet )
|
||||||
{
|
{
|
||||||
|
removed = true;
|
||||||
m_netCodes.erase(i);
|
m_netCodes.erase(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -96,12 +99,15 @@ void NETINFO_LIST::RemoveNet( NETINFO_ITEM* aNet )
|
||||||
{
|
{
|
||||||
if ( i->second == aNet )
|
if ( i->second == aNet )
|
||||||
{
|
{
|
||||||
|
wxASSERT_MSG( removed, "NETINFO_LIST::RemoveNet: target net found in m_netNames "
|
||||||
|
"but not m_netCodes!" );
|
||||||
m_netNames.erase(i);
|
m_netNames.erase(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_newNetCode = std::min( m_newNetCode, aNet->m_netCode - 1 );
|
if( removed )
|
||||||
|
m_newNetCode = std::min( m_newNetCode, aNet->m_netCode - 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue