From 87a82358310b9aaaecf7ab6a332b4bdde8e1d7c4 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Sun, 18 Feb 2024 17:01:30 +0000 Subject: [PATCH] Remove group from dummy track before deletion The dummy track in the merge colinear segments is used to overwrite the original segment with the changes at the end, so the group must be removed before leaving the function, and can't be removed at creation. Fixes KICAD-74M --- pcbnew/tracks_cleaner.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pcbnew/tracks_cleaner.cpp b/pcbnew/tracks_cleaner.cpp index 7582393e66..2fcfa1040c 100644 --- a/pcbnew/tracks_cleaner.cpp +++ b/pcbnew/tracks_cleaner.cpp @@ -664,20 +664,29 @@ bool TRACKS_CLEANER::mergeCollinearSegments( PCB_TRACK* aSeg1, PCB_TRACK* aSeg2 for( auto& pt : pts ) { if( !dummy_seg.IsPointOnEnds( pt ) ) + { + dummy_seg.SetParentGroup( nullptr ); return false; + } } // Now find the removed end(s) and stop merging if it is a node: if( aSeg1->GetStart() != dummy_seg.GetStart() && aSeg1->GetStart() != dummy_seg.GetEnd() ) { if( testTrackEndpointIsNode( aSeg1, true ) ) + { + dummy_seg.SetParentGroup( nullptr ); return false; + } } if( aSeg1->GetEnd() != dummy_seg.GetStart() && aSeg1->GetEnd() != dummy_seg.GetEnd() ) { if( testTrackEndpointIsNode( aSeg1, false ) ) + { + dummy_seg.SetParentGroup( nullptr ); return false; + } } std::shared_ptr item = std::make_shared( CLEANUP_MERGE_TRACKS ); @@ -698,9 +707,10 @@ bool TRACKS_CLEANER::mergeCollinearSegments( PCB_TRACK* aSeg1, PCB_TRACK* aSeg2 m_commit.Removed( aSeg2 ); } - if( dummy_seg.GetParentGroup() ) - dummy_seg.SetParentGroup( nullptr ); - + // Note that dummy_seg is used to replace aSeg1 after processing, so the group membership must + // be kept until all processing has finished, and cannot be removed right after creation of the + // dummy object + dummy_seg.SetParentGroup( nullptr ); return true; }