search panel: fix a crash and a refresh issue after selecting a second item

at least on W10/msys2
This commit is contained in:
jean-pierre charras 2022-09-21 19:34:54 +02:00
parent b6663a1c41
commit c44e54756a
2 changed files with 23 additions and 6 deletions

View File

@ -40,6 +40,10 @@ SEARCH_PANE_LISTVIEW::SEARCH_PANE_LISTVIEW( SEARCH_HANDLER* handler, wxWindow* p
void SEARCH_PANE_LISTVIEW::GetSelectRowsList( std::vector<long>& aSelectedList )
{
long idx = GetFirstSelected();
if( idx < 0 ) // Nothing selected
return;
aSelectedList.emplace_back( idx );
idx = GetNextSelected( idx );

View File

@ -85,9 +85,10 @@ wxString FOOTPRINT_SEARCH_HANDLER::GetResultCell( int aRow, int aCol )
void FOOTPRINT_SEARCH_HANDLER::SelectItems( std::vector<long>& aItemRows )
{
std::vector<EDA_ITEM*> selectedItems;
for( long row : aItemRows )
{
if( row < (long)m_hitlist.size() )
if( row >= 0 && row < (long)m_hitlist.size() )
{
FOOTPRINT* fp = m_hitlist[row];
selectedItems.push_back( fp );
@ -95,7 +96,11 @@ void FOOTPRINT_SEARCH_HANDLER::SelectItems( std::vector<long>& aItemRows )
}
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectionClear, true );
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectItems, true, &selectedItems );
if( selectedItems.size() )
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectItems, true, &selectedItems );
m_frame->GetCanvas()->Refresh(0);
}
@ -170,7 +175,7 @@ void ZONE_SEARCH_HANDLER::SelectItems( std::vector<long>& aItemRows )
std::vector<EDA_ITEM*> selectedItems;
for( long row : aItemRows )
{
if( row < (long)m_hitlist.size() )
if( row >= 0 && row < (long)m_hitlist.size() )
{
ZONE* zone = m_hitlist[row];
selectedItems.push_back( zone );
@ -178,7 +183,11 @@ void ZONE_SEARCH_HANDLER::SelectItems( std::vector<long>& aItemRows )
}
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectionClear, true );
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectItems, true, &selectedItems );
if( selectedItems.size() )
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectItems, true, &selectedItems );
m_frame->GetCanvas()->Refresh(0);
}
@ -263,7 +272,7 @@ void TEXT_SEARCH_HANDLER::SelectItems( std::vector<long>& aItemRows )
std::vector<EDA_ITEM*> selectedItems;
for( long row : aItemRows )
{
if( row < (long)m_hitlist.size() )
if( row >= 0 && row < (long)m_hitlist.size() )
{
BOARD_ITEM* text = m_hitlist[row];
selectedItems.push_back( text );
@ -271,7 +280,11 @@ void TEXT_SEARCH_HANDLER::SelectItems( std::vector<long>& aItemRows )
}
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectionClear, true );
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectItems, true, &selectedItems );
if( selectedItems.size() )
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectItems, true, &selectedItems );
m_frame->GetCanvas()->Refresh(0);
}