Make sure we have nets before grabbing the first.

Fixes https://gitlab.com/kicad/code/kicad/issues/12554
This commit is contained in:
Jeff Young 2022-10-01 13:49:53 +01:00
parent 93239516d9
commit 7be05e9eb1
1 changed files with 12 additions and 11 deletions

View File

@ -466,16 +466,17 @@ bool ROUTER_TOOL::Init()
return !m_router->RoutingInProgress(); return !m_router->RoutingInProgress();
}; };
auto hasOtherEnd = [&]( const SELECTION& ) auto hasOtherEnd =
[&]( const SELECTION& )
{ {
std::vector<int> currentNets = m_router->GetCurrentNets();
// Need to have something unconnected to finish to // Need to have something unconnected to finish to
return getEditFrame<PCB_EDIT_FRAME>() int currentNet = currentNets.empty() ? -1 : currentNets[0];
->GetBoard() BOARD* board = getEditFrame<PCB_EDIT_FRAME>()->GetBoard();
->GetConnectivity() RN_NET* ratsnest = board->GetConnectivity()->GetRatsnestForNet( currentNet );
->GetRatsnestForNet( m_router->GetCurrentNets()[0] )
->GetEdges() return ratsnest && !ratsnest->GetEdges().empty();
.size()
> 0;
}; };
menu.AddItem( ACTIONS::cancelInteractive, SELECTION_CONDITIONS::ShowAlways, 1 ); menu.AddItem( ACTIONS::cancelInteractive, SELECTION_CONDITIONS::ShowAlways, 1 );