Fixed segfault in connectivity algo for boards with orphaned nets

Fixes: lp:1701347
* https://bugs.launchpad.net/kicad/+bug/1701347
This commit is contained in:
Tomasz Włostowski 2017-06-30 00:45:50 +02:00
parent bafb8c3688
commit d6820bc925
5 changed files with 22 additions and 6 deletions

View File

@ -757,7 +757,11 @@ void BOARD::SetElementVisibility( GAL_LAYER_ID LAYER_aPCB, bool isEnabled )
// so the hide/show option is a per item selection
for( unsigned int net = 1; net < GetNetCount(); net++ )
GetConnectivity()->GetRatsnestForNet( net )->SetVisible( visible );
{
auto rn = GetConnectivity()->GetRatsnestForNet( net );
if( rn )
rn->SetVisible( visible );
}
for( auto track : Tracks() )
track->SetLocalRatsnestVisible( isEnabled );

View File

@ -566,3 +566,12 @@ const std::vector<BOARD_CONNECTED_ITEM*> CONNECTIVITY_DATA::GetConnectedItems(
return rv;
}
RN_NET* CONNECTIVITY_DATA::GetRatsnestForNet( int aNet )
{
if ( aNet < 0 || aNet >= m_nets.size() )
{
return nullptr;
}
return m_nets[ aNet ];
}

View File

@ -122,10 +122,7 @@ public:
* Function GetRatsnestForNet()
* Returns the ratsnest, expressed as a set of graph edges for a given net.
*/
RN_NET* GetRatsnestForNet( int aNet )
{
return m_nets[aNet];
}
RN_NET* GetRatsnestForNet( int aNet );
/**
* Function PropagateNets()

View File

@ -103,6 +103,9 @@ void PCB_BASE_FRAME::DrawGeneralRatsnest( wxDC* aDC, int aNetcode )
{
RN_NET* net = connectivity->GetRatsnestForNet( i );
if( !net )
continue;
if( ( aNetcode <= 0 ) || ( aNetcode == i ) )
{
for( const auto& edge : net->GetEdges() )

View File

@ -86,6 +86,9 @@ void RATSNEST_VIEWITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
{
RN_NET* net = m_data->GetRatsnestForNet( i );
if( !net )
continue;
// Draw the "static" ratsnest
if( i != highlightedNet )
gal->SetStrokeColor( color ); // using the default ratsnest color for not highlighted