Fix invalid dereference on first highlight

When highlighting nets we don't save the previous net when there isn't a
previous net highlighted.
This commit is contained in:
Seth Hillbrand 2020-06-23 20:36:05 -07:00
parent 141bf4f579
commit 1a7c270dcd
1 changed files with 7 additions and 3 deletions

View File

@ -174,14 +174,18 @@ int PCB_INSPECTION_TOOL::HighlightItem( const TOOL_EVENT& aEvent )
net = static_cast<BOARD_CONNECTED_ITEM*>( collector[0] )->GetNetCode(); net = static_cast<BOARD_CONNECTED_ITEM*>( collector[0] )->GetNetCode();
} }
auto& netcodes = settings->GetHighlightNetCodes();
// Toggle highlight when the same net was picked // Toggle highlight when the same net was picked
if( net > 0 && settings->GetHighlightNetCodes().count( net ) ) if( net > 0 && netcodes.count( net ) )
enableHighlight = !settings->IsHighlightEnabled(); enableHighlight = !settings->IsHighlightEnabled();
if( enableHighlight != settings->IsHighlightEnabled() if( enableHighlight != settings->IsHighlightEnabled()
|| !settings->GetHighlightNetCodes().count( net ) ) || !netcodes.count( net ) )
{ {
m_lastNetcode = *settings->GetHighlightNetCodes().begin(); if( !netcodes.empty() )
m_lastNetcode = *netcodes.begin();
settings->SetHighlight( enableHighlight, net ); settings->SetHighlight( enableHighlight, net );
m_toolMgr->GetView()->UpdateAllLayersColor(); m_toolMgr->GetView()->UpdateAllLayersColor();
} }