Careful of net[0]; it's "No Net", not a real net.

Fixes: lp:1792235
* https://bugs.launchpad.net/kicad/+bug/1792235
This commit is contained in:
Jeff Young 2018-09-21 13:41:28 +01:00
parent e985f797c3
commit 9a5334478b
5 changed files with 13 additions and 11 deletions

View File

@ -816,7 +816,7 @@ void BOARD::SetElementVisibility( GAL_LAYER_ID aLayer, bool isEnabled )
// because we have a tool to show/hide ratsnest relative to a pad or a module
// so the hide/show option is a per item selection
for( unsigned int net = 1; net < GetNetCount(); net++ )
for( unsigned int net = 1 /* skip "No Net" at [0] */; net < GetNetCount(); net++ )
{
auto rn = GetConnectivity()->GetRatsnestForNet( net );
if( rn )
@ -1211,8 +1211,7 @@ void BOARD::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >&
txt.Printf( wxT( "%d" ), GetNodesCount() );
aList.push_back( MSG_PANEL_ITEM( _( "Nodes" ), txt, DARKCYAN ) );
// Subtract out the unconnected net before reporting number of nets
txt.Printf( wxT( "%d" ), m_NetInfo.GetNetCount() - 1 );
txt.Printf( wxT( "%d" ), m_NetInfo.GetNetCount() - 1 /* Don't include "No Net" in count */ );
aList.push_back( MSG_PANEL_ITEM( _( "Nets" ), txt, RED ) );
txt.Printf( wxT( "%d" ), GetConnectivity()->GetUnconnectedCount() );
@ -1408,7 +1407,7 @@ NETINFO_ITEM* BOARD::FindNet( int aNetcode ) const
// zero is reserved for "no connection" and is not actually a net.
// NULL is returned for non valid netcodes
wxASSERT( m_NetInfo.GetNetCount() > 0 ); // net zero should exist
wxASSERT( m_NetInfo.GetNetCount() > 0 );
if( aNetcode == NETINFO_LIST::UNCONNECTED && m_NetInfo.GetNetCount() == 0 )
return &NETINFO_LIST::ORPHANED_ITEM;

View File

@ -364,7 +364,7 @@ void PCB_DRAW_PANEL_GAL::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector<MSG_PA
txt.Printf( wxT( "%d" ), board->GetNodesCount() );
aList.push_back( MSG_PANEL_ITEM( _( "Nodes" ), txt, DARKCYAN ) );
txt.Printf( wxT( "%d" ), board->GetNetCount() );
txt.Printf( wxT( "%d" ), board->GetNetCount() - 1 /* don't include "No Net" in count */ );
aList.push_back( MSG_PANEL_ITEM( _( "Nets" ), txt, RED ) );
txt.Printf( wxT( "%d" ), board->GetConnectivity()->GetUnconnectedCount() );

View File

@ -66,10 +66,14 @@ void PCB_BASE_FRAME::Compile_Ratsnest( wxDC* aDC, bool aDisplayStatus )
if( aDisplayStatus )
{
msg.Printf( wxT( " %d" ), m_Pcb->GetConnectivity()->GetPadCount() );
std::shared_ptr<CONNECTIVITY_DATA> conn = m_Pcb->GetConnectivity();
msg.Printf( wxT( " %d" ), conn->GetPadCount() );
AppendMsgPanel( wxT( "Pads" ), msg, RED );
msg.Printf( wxT( " %d" ), m_Pcb->GetConnectivity()->GetNetCount() );
msg.Printf( wxT( " %d" ), conn->GetNetCount() - 1 /* Don't include "No Net" in count */ );
AppendMsgPanel( wxT( "Nets" ), msg, CYAN );
SetMsgPanel( m_Pcb );
}
}
@ -99,7 +103,7 @@ void PCB_BASE_FRAME::DrawGeneralRatsnest( wxDC* aDC, int aNetcode )
COLOR4D color = Settings().Colors().GetItemColor( LAYER_RATSNEST );
for( int i = 1; i < connectivity->GetNetCount(); ++i )
for( int i = 1 /* skip "No Net" at [0] */; i < connectivity->GetNetCount(); ++i )
{
RN_NET* net = connectivity->GetRatsnestForNet( i );

View File

@ -86,7 +86,7 @@ void RATSNEST_VIEWITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
}
}
for( int i = 1; i < m_data->GetNetCount(); ++i )
for( int i = 1 /* skip "No Net" at [0] */; i < m_data->GetNetCount(); ++i )
{
RN_NET* net = m_data->GetRatsnestForNet( i );

View File

@ -1340,8 +1340,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
// expand the net vector to highestNetCode+1, setting empty to NULL
nets.resize( highestNetCode + 1, NULL );
// skip netcode = 0
for( unsigned i = 1; i<nets.size(); ++i )
for( unsigned i = 1 /* skip "No Net" at [0] */; i < nets.size(); ++i )
nets[i] = new NET( pcb->network );
for( unsigned ii = 0; ii < aBoard->GetNetCount(); ii++ )