Fix a search pane crash when a row isn't in the hit list.

Fixes KICAD-Q7
Fixes KICAD-1A6

Cherry-picked from f071dd1406
This commit is contained in:
Alex Shvartzkop 2023-08-25 23:24:32 +03:00
parent 33c2005c18
commit 9672390104
1 changed files with 24 additions and 0 deletions

View File

@ -81,8 +81,14 @@ int FOOTPRINT_SEARCH_HANDLER::Search( const wxString& aQuery )
wxString FOOTPRINT_SEARCH_HANDLER::GetResultCell( int aRow, int aCol )
{
if( aRow >= m_hitlist.size() )
return wxEmptyString;
FOOTPRINT* fp = m_hitlist[aRow];
if( !fp )
return wxEmptyString;
if( aCol == 0 )
return fp->GetReference();
else if( aCol == 1 )
@ -155,8 +161,14 @@ int ZONE_SEARCH_HANDLER::Search( const wxString& aQuery )
wxString ZONE_SEARCH_HANDLER::GetResultCell( int aRow, int aCol )
{
if( aRow >= m_hitlist.size() )
return wxEmptyString;
ZONE* zone = m_hitlist[aRow];
if( !zone )
return wxEmptyString;
if( aCol == 0 )
return zone->GetZoneName();
if( aCol == 1 )
@ -241,8 +253,14 @@ int TEXT_SEARCH_HANDLER::Search( const wxString& aQuery )
wxString TEXT_SEARCH_HANDLER::GetResultCell( int aRow, int aCol )
{
if( aRow >= m_hitlist.size() )
return wxEmptyString;
BOARD_ITEM* text = m_hitlist[aRow];
if( !text )
return wxEmptyString;
if( aCol == 0 )
{
if( PCB_TEXT::ClassOf( text ) )
@ -320,8 +338,14 @@ int NETS_SEARCH_HANDLER::Search( const wxString& aQuery )
wxString NETS_SEARCH_HANDLER::GetResultCell( int aRow, int aCol )
{
if( aRow >= m_hitlist.size() )
return wxEmptyString;
NETINFO_ITEM* net = m_hitlist[aRow];
if( !net )
return wxEmptyString;
if( net->GetNetCode() == 0 )
{
if( aCol == 0 )