From 885979ba75e7e163ae66396ccb4faa8f8f99ae2a Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 12 Dec 2021 17:38:16 +0000 Subject: [PATCH] Fix selection logic to handle LIB_ITEM as well as SCH_ITEM. Fixes https://gitlab.com/kicad/code/kicad/issues/9954 --- eeschema/tools/ee_selection_tool.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index e1a1a652fd..8138252c7d 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -1233,19 +1233,22 @@ 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 nearbyItems; + std::vector nearbyChildren; for( KIGFX::VIEW::LAYER_ITEM_PAIR& pair : nearbyViewItems ) { - SCH_ITEM* item = dynamic_cast( pair.first ); + EDA_ITEM* item = dynamic_cast( pair.first ); if( item ) { item->ClearFlags( TEMP_SELECTED | STARTPOINT | ENDPOINT ); nearbyItems.push_back( item ); + } - item->RunOnChildren( + if( SCH_ITEM* sch_item = dynamic_cast( item ) ) + { + sch_item->RunOnChildren( [&]( SCH_ITEM* aChild ) { nearbyChildren.push_back( aChild ); @@ -1259,7 +1262,7 @@ bool EE_SELECTION_TOOL::selectMultiple() bool anyAdded = false; bool anySubtracted = false; auto selectItem = - [&]( SCH_ITEM* aItem ) + [&]( EDA_ITEM* aItem ) { if( m_subtractive || ( m_exclusive_or && aItem->IsSelected() ) ) { @@ -1274,7 +1277,7 @@ bool EE_SELECTION_TOOL::selectMultiple() } }; - for( SCH_ITEM* item : nearbyItems ) + for( EDA_ITEM* item : nearbyItems ) { if( Selectable( item ) && item->HitTest( selectionRect, isWindowSelection ) ) { @@ -1283,7 +1286,7 @@ bool EE_SELECTION_TOOL::selectMultiple() } } - for( SCH_ITEM* item : nearbyChildren ) + for( EDA_ITEM* item : nearbyChildren ) { if( Selectable( item ) && !item->GetParent()->HasFlag( TEMP_SELECTED )