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
This commit is contained in:
Ian McInerney 2024-02-18 17:01:30 +00:00 committed by Ian McInerney
parent 9456f35491
commit 87a8235831
1 changed files with 13 additions and 3 deletions

View File

@ -664,20 +664,29 @@ bool TRACKS_CLEANER::mergeCollinearSegments( PCB_TRACK* aSeg1, PCB_TRACK* aSeg2
for( auto& pt : pts ) for( auto& pt : pts )
{ {
if( !dummy_seg.IsPointOnEnds( pt ) ) if( !dummy_seg.IsPointOnEnds( pt ) )
{
dummy_seg.SetParentGroup( nullptr );
return false; return false;
}
} }
// Now find the removed end(s) and stop merging if it is a node: // 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( aSeg1->GetStart() != dummy_seg.GetStart() && aSeg1->GetStart() != dummy_seg.GetEnd() )
{ {
if( testTrackEndpointIsNode( aSeg1, true ) ) if( testTrackEndpointIsNode( aSeg1, true ) )
{
dummy_seg.SetParentGroup( nullptr );
return false; return false;
}
} }
if( aSeg1->GetEnd() != dummy_seg.GetStart() && aSeg1->GetEnd() != dummy_seg.GetEnd() ) if( aSeg1->GetEnd() != dummy_seg.GetStart() && aSeg1->GetEnd() != dummy_seg.GetEnd() )
{ {
if( testTrackEndpointIsNode( aSeg1, false ) ) if( testTrackEndpointIsNode( aSeg1, false ) )
{
dummy_seg.SetParentGroup( nullptr );
return false; return false;
}
} }
std::shared_ptr<CLEANUP_ITEM> item = std::make_shared<CLEANUP_ITEM>( CLEANUP_MERGE_TRACKS ); std::shared_ptr<CLEANUP_ITEM> item = std::make_shared<CLEANUP_ITEM>( CLEANUP_MERGE_TRACKS );
@ -698,9 +707,10 @@ bool TRACKS_CLEANER::mergeCollinearSegments( PCB_TRACK* aSeg1, PCB_TRACK* aSeg2
m_commit.Removed( aSeg2 ); m_commit.Removed( aSeg2 );
} }
if( dummy_seg.GetParentGroup() ) // Note that dummy_seg is used to replace aSeg1 after processing, so the group membership must
dummy_seg.SetParentGroup( nullptr ); // be kept until all processing has finished, and cannot be removed right after creation of the
// dummy object
dummy_seg.SetParentGroup( nullptr );
return true; return true;
} }