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 );
|
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;
|
continue;
|
||||||
|
|
||||||
m_pins.push_back( std::make_unique<SCH_PIN>( libPin, this ) );
|
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 )
|
if( m_unit != aUnit )
|
||||||
{
|
{
|
||||||
m_unit = aUnit;
|
UpdateUnit( aUnit );
|
||||||
SetModified();
|
SetModified();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -377,7 +380,13 @@ void SCH_SYMBOL::SetUnit( int aUnit )
|
||||||
|
|
||||||
void SCH_SYMBOL::UpdateUnit( int aUnit )
|
void SCH_SYMBOL::UpdateUnit( int aUnit )
|
||||||
{
|
{
|
||||||
m_unit = aUnit;
|
if( m_unit != aUnit )
|
||||||
|
{
|
||||||
|
m_unit = aUnit;
|
||||||
|
|
||||||
|
// The unit may have a different pins so the update the pin map.
|
||||||
|
UpdatePins();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1218,11 +1218,7 @@ bool EE_SELECTION_TOOL::selectMultiple()
|
||||||
{
|
{
|
||||||
bool cancelled = false; // Was the tool canceled while it was running?
|
bool cancelled = false; // Was the tool canceled while it was running?
|
||||||
m_multiple = true; // Multiple selection mode is active
|
m_multiple = true; // Multiple selection mode is active
|
||||||
KIGFX::VIEW* view = getView();
|
KIGFX::VIEW* view = getView();
|
||||||
SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
|
|
||||||
|
|
||||||
if( !editFrame )
|
|
||||||
return cancelled;
|
|
||||||
|
|
||||||
KIGFX::PREVIEW::SELECTION_AREA area;
|
KIGFX::PREVIEW::SELECTION_AREA area;
|
||||||
view->Add( &area );
|
view->Add( &area );
|
||||||
|
@ -1279,49 +1275,25 @@ bool EE_SELECTION_TOOL::selectMultiple()
|
||||||
view->Query( area.ViewBBox(), nearbyViewItems );
|
view->Query( area.ViewBBox(), nearbyViewItems );
|
||||||
|
|
||||||
// Build lists of nearby items and their children
|
// 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*> nearbyChildren;
|
||||||
std::vector<EDA_ITEM*> flaggedItems;
|
std::vector<EDA_ITEM*> flaggedItems;
|
||||||
|
|
||||||
for( KIGFX::VIEW::LAYER_ITEM_PAIR& pair : nearbyViewItems )
|
for( KIGFX::VIEW::LAYER_ITEM_PAIR& pair : nearbyViewItems )
|
||||||
{
|
{
|
||||||
EDA_ITEM* item = dynamic_cast<EDA_ITEM*>( pair.first );
|
if( EDA_ITEM* item = dynamic_cast<EDA_ITEM*>( pair.first ) )
|
||||||
|
|
||||||
if( !item )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
item->ClearFlags( CANDIDATE );
|
|
||||||
auto emplaceRet = nearbyItems.emplace( 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() );
|
item->ClearFlags( CANDIDATE );
|
||||||
|
nearbyItems.push_back( item );
|
||||||
|
|
||||||
symbol->RunOnChildren(
|
if( SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( item ) )
|
||||||
[&]( SCH_ITEM* aChild )
|
{
|
||||||
{
|
sch_item->RunOnChildren(
|
||||||
// Filter pins by unit
|
[&]( SCH_ITEM* aChild )
|
||||||
SCH_PIN* pin = dyn_cast<SCH_PIN*>( aChild );
|
|
||||||
|
|
||||||
if( pin && unit && pin->GetLibPin()->GetUnit()
|
|
||||||
&& ( pin->GetLibPin()->GetUnit() != unit ) )
|
|
||||||
{
|
{
|
||||||
return;
|
nearbyChildren.push_back( aChild );
|
||||||
}
|
} );
|
||||||
|
}
|
||||||
nearbyChildren.push_back( aChild );
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
else if( SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( item ) )
|
|
||||||
{
|
|
||||||
sch_item->RunOnChildren(
|
|
||||||
[&]( SCH_ITEM* aChild )
|
|
||||||
{
|
|
||||||
nearbyChildren.push_back( aChild );
|
|
||||||
} );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue