DIALOG_CONFIGURE_PATHS: Fix crash when deleting the last item in list.

When the list (in 3D search path list) contains only one item, when trying
to remove this last item, the crash happened.
This commit is contained in:
jean-pierre charras 2020-04-30 20:42:20 +02:00
parent 93b9be7ebe
commit b7e7d6fd5c
1 changed files with 6 additions and 2 deletions

View File

@ -413,8 +413,12 @@ void DIALOG_CONFIGURE_PATHS::OnDeleteSearchPath( wxCommandEvent& event )
m_SearchPaths->CommitPendingChanges( true /* silent mode; we don't care if it's valid */ ); m_SearchPaths->CommitPendingChanges( true /* silent mode; we don't care if it's valid */ );
m_SearchPaths->DeleteRows( curRow, 1 ); m_SearchPaths->DeleteRows( curRow, 1 );
m_SearchPaths->MakeCellVisible( std::max( 0, curRow-1 ), m_SearchPaths->GetGridCursorCol() ); // if there are still rows in grid, make previous row visible
m_SearchPaths->SetGridCursor( std::max( 0, curRow-1 ), m_SearchPaths->GetGridCursorCol() ); if( m_SearchPaths->GetNumberRows() )
{
m_SearchPaths->MakeCellVisible( std::max( 0, curRow-1 ), m_SearchPaths->GetGridCursorCol() );
m_SearchPaths->SetGridCursor( std::max( 0, curRow-1 ), m_SearchPaths->GetGridCursorCol() );
}
} }