Browse Source

static_cast safety.

pull/18/head
Jeff Young 3 months ago
parent
commit
f5d2553161
  1. 13
      eeschema/tools/sch_selection_tool.cpp
  2. 7
      pcbnew/tools/pcb_selection_tool.cpp

13
eeschema/tools/sch_selection_tool.cpp

@ -2160,12 +2160,10 @@ bool SCH_SELECTION_TOOL::selectMultiple()
// Ensure candidates only have unique items
std::set<SCH_ITEM*> uniqueCandidates;
for( const auto& candidate : candidates )
for( const auto& [viewItem, layer] : candidates )
{
SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( candidate.first );
if( schItem )
uniqueCandidates.insert( schItem );
if( viewItem->IsSCH_ITEM() )
uniqueCandidates.insert( static_cast<SCH_ITEM*>( viewItem ) );
}
for( KIGFX::VIEW_ITEM* item : uniqueCandidates )
@ -2192,7 +2190,7 @@ bool SCH_SELECTION_TOOL::selectMultiple()
}
}
// Construct a BOX2I to determine BOARD_ITEM selection
// Construct a BOX2I to determine SCH_ITEM selection
BOX2I selectionRect( area.GetOrigin(), VECTOR2I( width, height ) );
// Build lists of nearby items and their children
@ -2216,6 +2214,9 @@ bool SCH_SELECTION_TOOL::selectMultiple()
{
for( EDA_ITEM* group_item : newset )
{
if( !group_item->IsSCH_ITEM() )
continue;
if( Selectable( static_cast<SCH_ITEM*>( group_item ) ) )
collector.Append( *newset.begin() );
}

7
pcbnew/tools/pcb_selection_tool.cpp

@ -1147,6 +1147,9 @@ bool PCB_SELECTION_TOOL::selectMultiple()
{
for( EDA_ITEM* group_item : newset )
{
if( !group_item->IsBOARD_ITEM() )
continue;
if( Selectable( static_cast<BOARD_ITEM*>( group_item ) ) )
collector.Append( *newset.begin() );
}
@ -1156,12 +1159,12 @@ bool PCB_SELECTION_TOOL::selectMultiple()
group_items.emplace( group_item );
}
for( const KIGFX::VIEW::LAYER_ITEM_PAIR& candidate : candidates )
for( const auto& [item, layer] : candidates )
{
if( !candidate.first->IsBOARD_ITEM() )
continue;
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( candidate.first );
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( item );
if( item && Selectable( item ) && item->HitTest( selectionRect, !greedySelection )
&& ( greedySelection || !group_items.count( item ) ) )

Loading…
Cancel
Save