Don't assume a SCH_EDIT_FRAME in EE_SELECTION_TOOL.
It's also used in the symbol editor. But in any case, pins of other units have no business being in an SCH_SYMBOL anyway. Fixes https://gitlab.com/kicad/code/kicad/issues/12076
This commit is contained in:
parent
f0ef6932b8
commit
cb77e68076
|
@ -343,7 +343,10 @@ void SCH_SYMBOL::UpdatePins()
|
|||
{
|
||||
wxASSERT( libPin->Type() == LIB_PIN_T );
|
||||
|
||||
if( libPin->GetConvert() && m_convert && ( m_convert != libPin->GetConvert() ) )
|
||||
if( libPin->GetConvert() && m_convert && m_convert != libPin->GetConvert() )
|
||||
continue;
|
||||
|
||||
if( libPin->GetUnit() && m_unit && m_unit != libPin->GetUnit() )
|
||||
continue;
|
||||
|
||||
m_pins.push_back( std::make_unique<SCH_PIN>( libPin, this ) );
|
||||
|
@ -369,7 +372,7 @@ void SCH_SYMBOL::SetUnit( int aUnit )
|
|||
{
|
||||
if( m_unit != aUnit )
|
||||
{
|
||||
m_unit = aUnit;
|
||||
UpdateUnit( aUnit );
|
||||
SetModified();
|
||||
}
|
||||
}
|
||||
|
@ -377,7 +380,13 @@ void SCH_SYMBOL::SetUnit( int aUnit )
|
|||
|
||||
void SCH_SYMBOL::UpdateUnit( int aUnit )
|
||||
{
|
||||
if( m_unit != aUnit )
|
||||
{
|
||||
m_unit = aUnit;
|
||||
|
||||
// The unit may have a different pins so the update the pin map.
|
||||
UpdatePins();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1219,10 +1219,6 @@ bool EE_SELECTION_TOOL::selectMultiple()
|
|||
bool cancelled = false; // Was the tool canceled while it was running?
|
||||
m_multiple = true; // Multiple selection mode is active
|
||||
KIGFX::VIEW* view = getView();
|
||||
SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
|
||||
|
||||
if( !editFrame )
|
||||
return cancelled;
|
||||
|
||||
KIGFX::PREVIEW::SELECTION_AREA area;
|
||||
view->Add( &area );
|
||||
|
@ -1279,43 +1275,18 @@ bool EE_SELECTION_TOOL::selectMultiple()
|
|||
view->Query( area.ViewBBox(), nearbyViewItems );
|
||||
|
||||
// Build lists of nearby items and their children
|
||||
std::unordered_set<EDA_ITEM*> nearbyItems;
|
||||
std::vector<EDA_ITEM*> nearbyItems;
|
||||
std::vector<EDA_ITEM*> nearbyChildren;
|
||||
std::vector<EDA_ITEM*> flaggedItems;
|
||||
|
||||
for( KIGFX::VIEW::LAYER_ITEM_PAIR& pair : nearbyViewItems )
|
||||
{
|
||||
EDA_ITEM* item = dynamic_cast<EDA_ITEM*>( pair.first );
|
||||
|
||||
if( !item )
|
||||
continue;
|
||||
|
||||
if( EDA_ITEM* item = dynamic_cast<EDA_ITEM*>( pair.first ) )
|
||||
{
|
||||
item->ClearFlags( CANDIDATE );
|
||||
auto emplaceRet = nearbyItems.emplace( item );
|
||||
nearbyItems.push_back( item );
|
||||
|
||||
if( !emplaceRet.second )
|
||||
continue; // Item already in set
|
||||
|
||||
if( SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item ) )
|
||||
{
|
||||
int unit = symbol->GetUnitSelection( &editFrame->Schematic().CurrentSheet() );
|
||||
|
||||
symbol->RunOnChildren(
|
||||
[&]( SCH_ITEM* aChild )
|
||||
{
|
||||
// Filter pins by unit
|
||||
SCH_PIN* pin = dyn_cast<SCH_PIN*>( aChild );
|
||||
|
||||
if( pin && unit && pin->GetLibPin()->GetUnit()
|
||||
&& ( pin->GetLibPin()->GetUnit() != unit ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
nearbyChildren.push_back( aChild );
|
||||
} );
|
||||
}
|
||||
else if( SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( item ) )
|
||||
if( SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( item ) )
|
||||
{
|
||||
sch_item->RunOnChildren(
|
||||
[&]( SCH_ITEM* aChild )
|
||||
|
@ -1324,6 +1295,7 @@ bool EE_SELECTION_TOOL::selectMultiple()
|
|||
} );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EDA_RECT selectionRect( area.GetOrigin(), wxSize( width, height ) );
|
||||
selectionRect.Normalize();
|
||||
|
|
Loading…
Reference in New Issue