From 1a7c270dcda7d71d01ff3b1b037d00001fcceb05 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Tue, 23 Jun 2020 20:36:05 -0700 Subject: [PATCH] Fix invalid dereference on first highlight When highlighting nets we don't save the previous net when there isn't a previous net highlighted. --- pcbnew/tools/pcb_inspection_tool.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pcbnew/tools/pcb_inspection_tool.cpp b/pcbnew/tools/pcb_inspection_tool.cpp index 3492d8beb1..cc8cff7663 100644 --- a/pcbnew/tools/pcb_inspection_tool.cpp +++ b/pcbnew/tools/pcb_inspection_tool.cpp @@ -174,14 +174,18 @@ int PCB_INSPECTION_TOOL::HighlightItem( const TOOL_EVENT& aEvent ) net = static_cast( collector[0] )->GetNetCode(); } + auto& netcodes = settings->GetHighlightNetCodes(); + // Toggle highlight when the same net was picked - if( net > 0 && settings->GetHighlightNetCodes().count( net ) ) + if( net > 0 && netcodes.count( net ) ) 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 ); m_toolMgr->GetView()->UpdateAllLayersColor(); }