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. https://gitlab.com/kicad/code/kicad/-/issues/16088
This commit is contained in:
parent
0de966f9ce
commit
9e1caa0d39
|
@ -79,6 +79,7 @@ void ARRAY_CREATOR::Invoke()
|
||||||
for( int ptN = 0; ptN < array_opts->GetArraySize(); ptN++ )
|
for( int ptN = 0; ptN < array_opts->GetArraySize(); ptN++ )
|
||||||
{
|
{
|
||||||
PCB_SELECTION items_for_this_block;
|
PCB_SELECTION items_for_this_block;
|
||||||
|
std::set<FOOTPRINT*> fpDeDupe;
|
||||||
|
|
||||||
for ( int i = 0; i < m_selection.Size(); ++i )
|
for ( int i = 0; i < m_selection.Size(); ++i )
|
||||||
{
|
{
|
||||||
|
@ -87,10 +88,24 @@ void ARRAY_CREATOR::Invoke()
|
||||||
if( !item )
|
if( !item )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
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
|
// It is possible to select multiple footprint child objects in the board editor.
|
||||||
item = item->GetParentFootprint();
|
// 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;
|
BOARD_ITEM* this_item = nullptr;
|
||||||
|
|
Loading…
Reference in New Issue