From 8d52dc945169f198f1416fc545b04886f8706486 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Tue, 22 May 2018 16:20:54 -0700 Subject: [PATCH] Avoid re-checking items already selected If you select a track with many segments (e.g. a length-tuned track) and then select all connected items again ('U' -> 'U'), we would iterate over all items in the selection and mark connections for each of the n segments n separate times. We avoid this by using the marked flag to show when the segment has already been visited by the routine. This means that if the segment has been checked for connections because it was connected to the previous item, it won't be checked for connections again. However, a selection that interleaves items from multiple connection segments will still (potentially) be multiply checked as the BUSY flag is cleared each time there is one not-BUSY track in the selection. --- pcbnew/tools/selection_tool.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index 138740afdd..398f2661ed 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -863,11 +863,17 @@ int SELECTION_TOOL::expandSelectedConnection( const TOOL_EVENT& aEvent ) // copy the selection, since we're going to iterate and modify auto selection = m_selection.GetItems(); + // We use the BUSY flag to mark connections + for( auto item : selection ) + item->SetState( BUSY, false ); + for( auto item : selection ) { TRACK* trackItem = dynamic_cast( item ); - if( trackItem ) + // Track items marked BUSY have already been visited + // therefore their connections have already been marked + if( trackItem && !trackItem->GetState( BUSY ) ) selectAllItemsConnectedToTrack( *trackItem ); }