Don't crash on empty selection in search list.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/14931
This commit is contained in:
parent
782c73300b
commit
28075e6efe
|
@ -76,6 +76,8 @@ void SCH_SEARCH_HANDLER::SelectItems( std::vector<long>& aItemRows )
|
||||||
EDA_ITEMS selectedItems;
|
EDA_ITEMS selectedItems;
|
||||||
std::vector<SCH_SEARCH_HIT> selectedHits;
|
std::vector<SCH_SEARCH_HIT> selectedHits;
|
||||||
|
|
||||||
|
m_frame->GetToolManager()->RunAction( EE_ACTIONS::clearSelection, true );
|
||||||
|
|
||||||
for( long row : aItemRows )
|
for( long row : aItemRows )
|
||||||
{
|
{
|
||||||
if( row >= 0 && row < (long) m_hitlist.size() )
|
if( row >= 0 && row < (long) m_hitlist.size() )
|
||||||
|
@ -85,14 +87,15 @@ void SCH_SEARCH_HANDLER::SelectItems( std::vector<long>& aItemRows )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( selectedHits.empty() )
|
||||||
|
return;
|
||||||
|
|
||||||
bool allHitsOnSamePage = std::all_of( selectedHits.begin() + 1, selectedHits.end(),
|
bool allHitsOnSamePage = std::all_of( selectedHits.begin() + 1, selectedHits.end(),
|
||||||
[&]( const SCH_SEARCH_HIT& r )
|
[&]( const SCH_SEARCH_HIT& r )
|
||||||
{
|
{
|
||||||
return r.sheetPath == selectedHits.front().sheetPath;
|
return r.sheetPath == selectedHits.front().sheetPath;
|
||||||
} );
|
} );
|
||||||
|
|
||||||
m_frame->GetToolManager()->RunAction( EE_ACTIONS::clearSelection, true );
|
|
||||||
|
|
||||||
if( allHitsOnSamePage && !selectedHits.empty() )
|
if( allHitsOnSamePage && !selectedHits.empty() )
|
||||||
{
|
{
|
||||||
m_frame->SetCurrentSheet( *selectedHits.front().sheetPath );
|
m_frame->SetCurrentSheet( *selectedHits.front().sheetPath );
|
||||||
|
|
Loading…
Reference in New Issue