From 17fdb7c6a8ce0d6d94e36dae157f891d5855b71f Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Mon, 1 Aug 2022 08:56:11 -0700 Subject: [PATCH] Prevent drag index from exceeding full line count Simplification removes segments, so we might lose our valid index. Ideally, we would simplify during the assembly or pass the input index to the simplify routine to maintain the proper value. Fixes https://gitlab.com/kicad/code/kicad/issues/12137 (cherry picked from commit 6c617d84ca43abe5918e971f595b479af5aebb15) --- pcbnew/router/pns_node.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pcbnew/router/pns_node.cpp b/pcbnew/router/pns_node.cpp index 5862228cd9..60a591fd7f 100644 --- a/pcbnew/router/pns_node.cpp +++ b/pcbnew/router/pns_node.cpp @@ -1056,6 +1056,10 @@ const LINE NODE::AssembleLine( LINKED_ITEM* aSeg, int* aOriginSegmentIndex, // Remove duplicate verts, but do NOT remove colinear segments here! pl.Line().Simplify( false ); + // TODO: maintain actual segment index under simplifcation system + if( aOriginSegmentIndex && *aOriginSegmentIndex >= pl.SegmentCount() ) + *aOriginSegmentIndex = pl.SegmentCount() - 1; + assert( pl.SegmentCount() != 0 ); return pl;