Fix crash when creating an array of footprint fields in board editor.
Attempting to create an array of footprint child objects other than a pad
causes the crash due to the fact that only pads where checked. The change
now checks if any object has a footprint as a parent. This should prevent
any future issues when new footprint child objects are added.
There was also another subtle bug fixed when more than one child object of
a footprint were selected, the array feature would make as many copies of
the footprint as selected child items.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/16088
(cherry picked from commit 9e1caa0d39
)
This commit is contained in:
parent
70d7bc2099
commit
05890480e2
|
@ -79,15 +79,30 @@ void ARRAY_CREATOR::Invoke()
|
|||
for( int ptN = 0; ptN < array_opts->GetArraySize(); ptN++ )
|
||||
{
|
||||
PCB_SELECTION items_for_this_block;
|
||||
std::set<FOOTPRINT*> fpDeDupe;
|
||||
|
||||
for ( int i = 0; i < m_selection.Size(); ++i )
|
||||
{
|
||||
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( m_selection[ i ] );
|
||||
|
||||
if( item->Type() == PCB_PAD_T && !m_isFootprintEditor )
|
||||
FOOTPRINT* parentFootprint = dynamic_cast<FOOTPRINT*>( item->GetParentFootprint() );
|
||||
|
||||
// If it is not the footprint editor, then duplicate the parent footprint instead.
|
||||
// This check assumes that the footprint child objects are correctly parented, if
|
||||
// they are not, this will segfault.
|
||||
if( !m_isFootprintEditor && parentFootprint )
|
||||
{
|
||||
// If it is not the footprint editor, then duplicate the parent footprint instead
|
||||
item = static_cast<FOOTPRINT*>( item )->GetParent();
|
||||
// It is possible to select multiple footprint child objects in the board editor.
|
||||
// Do not create multiple copies of the same footprint when this occurs.
|
||||
if( fpDeDupe.count( parentFootprint ) == 0 )
|
||||
{
|
||||
fpDeDupe.emplace( parentFootprint );
|
||||
item = parentFootprint;
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
BOARD_ITEM* this_item = nullptr;
|
||||
|
|
Loading…
Reference in New Issue