diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 4bcd4b0aaf..ad0d1d6b63 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -1275,24 +1275,26 @@ bool EE_SELECTION_TOOL::selectMultiple() view->Query( area.ViewBBox(), nearbyViewItems ); // Build lists of nearby items and their children - std::vector nearbyItems; - std::vector nearbyChildren; - std::vector flaggedItems; + std::unordered_set nearbyItems; + std::vector nearbyChildren; + std::vector flaggedItems; for( KIGFX::VIEW::LAYER_ITEM_PAIR& pair : nearbyViewItems ) { if( EDA_ITEM* item = dynamic_cast( pair.first ) ) { - item->ClearFlags( CANDIDATE ); - nearbyItems.push_back( item ); - - if( SCH_ITEM* sch_item = dynamic_cast( item ) ) + if( nearbyItems.insert( item ).second ) { - sch_item->RunOnChildren( - [&]( SCH_ITEM* aChild ) - { - nearbyChildren.push_back( aChild ); - } ); + item->ClearFlags( CANDIDATE ); + + if( SCH_ITEM* sch_item = dynamic_cast( item ) ) + { + sch_item->RunOnChildren( + [&]( SCH_ITEM* aChild ) + { + nearbyChildren.push_back( aChild ); + } ); + } } } }