diff --git a/pcbnew/board.cpp b/pcbnew/board.cpp index caa9e27b6a..c3b490b268 100644 --- a/pcbnew/board.cpp +++ b/pcbnew/board.cpp @@ -673,25 +673,27 @@ void BOARD::Remove( BOARD_ITEM* aBoardItem, REMOVE_MODE aRemoveMode ) { NETINFO_ITEM* item = static_cast( 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 ) + if( pad->GetNet() == item ) pad->SetNet( unconnected ); } } for( ZONE* zone : m_zones ) { - if( zone->GetNetCode() == removedCode ) + if( zone->GetNet() == item ) zone->SetNet( unconnected ); } - for( TRACK* track : TracksInNet( removedCode ) ) - track->SetNet( unconnected ); + for( TRACK* track : m_tracks ) + { + if( track->GetNet() == item ) + track->SetNet( unconnected ); + } m_NetInfo.RemoveNet( item ); break; diff --git a/pcbnew/netinfo_list.cpp b/pcbnew/netinfo_list.cpp index d989ee7e22..fdb6c33e6f 100644 --- a/pcbnew/netinfo_list.cpp +++ b/pcbnew/netinfo_list.cpp @@ -83,10 +83,13 @@ NETINFO_ITEM* NETINFO_LIST::GetNetItem( const wxString& aNetName ) const void NETINFO_LIST::RemoveNet( NETINFO_ITEM* aNet ) { + bool removed = false; + for( NETCODES_MAP::iterator i = m_netCodes.begin(); i != m_netCodes.end(); ++i ) { if ( i->second == aNet ) { + removed = true; m_netCodes.erase(i); break; } @@ -96,12 +99,15 @@ void NETINFO_LIST::RemoveNet( NETINFO_ITEM* 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); break; } } - m_newNetCode = std::min( m_newNetCode, aNet->m_netCode - 1 ); + if( removed ) + m_newNetCode = std::min( m_newNetCode, aNet->m_netCode - 1 ); }