Prevent crash if generator exists but has no items

See https://gitlab.com/kicad/code/kicad/-/issues/15366
This commit is contained in:
Jon Evans 2023-11-25 16:01:12 -05:00
parent 1cb1fd3516
commit 37d9b7fac0
1 changed files with 15 additions and 4 deletions

View File

@ -2367,13 +2367,24 @@ bool PCB_SELECTION_TOOL::itemPassesFilter( BOARD_ITEM* aItem, bool aMultiSelect
}
}
if( aItem->Type() == PCB_GENERATOR_T )
aItem = *( static_cast<PCB_GENERATOR*>( aItem )->GetItems().begin() );
if( !aItem )
return false;
switch( aItem->Type() )
KICAD_T itemType = aItem->Type();
if( itemType == PCB_GENERATOR_T )
{
if( static_cast<PCB_GENERATOR*>( aItem )->GetItems().empty() )
{
wxASSERT_MSG( false, "Tried to select an empty generator" );
}
else
{
itemType = ( *static_cast<PCB_GENERATOR*>( aItem )->GetItems().begin() )->Type();
}
}
switch( itemType )
{
case PCB_FOOTPRINT_T:
if( !m_filter.footprints )