Don't dereference board groups in fp editor

The Footprint editor group resolution should stop at the footprint level
to avoid breaking into groups that cannot be accessed.

Fixes https://gitlab.com/kicad/code/kicad/issues/7049
This commit is contained in:
Seth Hillbrand 2021-01-11 14:56:56 -08:00
parent 63e2046eb0
commit 740df93808
3 changed files with 17 additions and 9 deletions

View File

@ -89,10 +89,11 @@ public:
/* /*
* Searches for highest level group containing item. * Searches for highest level group containing item.
* *
* @param scope restricts the search to groups within the group scope. * @param aScope restricts the search to groups within the group scope.
* @param aFootprintEditor true if we should stop promoting at the footprint level
* @return group containing item, if it exists, otherwise, NULL * @return group containing item, if it exists, otherwise, NULL
*/ */
static PCB_GROUP* TopLevelGroup( BOARD_ITEM* item, PCB_GROUP* scope ); static PCB_GROUP* TopLevelGroup( BOARD_ITEM* aItem, PCB_GROUP* aScope, bool aFootprintEditor );
static bool WithinScope( BOARD_ITEM* item, PCB_GROUP* scope ); static bool WithinScope( BOARD_ITEM* item, PCB_GROUP* scope );

View File

@ -69,17 +69,24 @@ void PCB_GROUP::RemoveAll()
} }
PCB_GROUP* PCB_GROUP::TopLevelGroup( BOARD_ITEM* item, PCB_GROUP* scope ) PCB_GROUP* PCB_GROUP::TopLevelGroup( BOARD_ITEM* aItem, PCB_GROUP* aScope, bool aFootprintEditor )
{ {
PCB_GROUP* candidate = item->GetParentGroup(); PCB_GROUP* candidate = aItem->GetParentGroup();
if( !candidate && item->GetParent() && item->GetParent()->Type() == PCB_FOOTPRINT_T ) // Don't get the footprint's group if we are in the footprint editor
candidate = item->GetParent()->GetParentGroup(); if( !candidate && aItem->GetParent() && aItem->GetParent()->Type() == PCB_FOOTPRINT_T
&& !aFootprintEditor )
candidate = aItem->GetParent()->GetParentGroup();
while( candidate && candidate->GetParentGroup() && candidate->GetParentGroup() != aScope )
{
if( candidate->GetParent()->Type() == PCB_FOOTPRINT_T && aFootprintEditor )
break;
while( candidate && candidate->GetParentGroup() && candidate->GetParentGroup() != scope )
candidate = candidate->GetParentGroup(); candidate = candidate->GetParentGroup();
}
return candidate == scope ? nullptr : candidate; return candidate == aScope ? nullptr : candidate;
} }

View File

@ -2497,7 +2497,7 @@ void PCB_SELECTION_TOOL::FilterCollectorForGroups( GENERAL_COLLECTOR& aCollector
continue; continue;
} }
PCB_GROUP* aTop = PCB_GROUP::TopLevelGroup( item, m_enteredGroup ); PCB_GROUP* aTop = PCB_GROUP::TopLevelGroup( item, m_enteredGroup, m_isFootprintEditor );
if( aTop ) if( aTop )
{ {