From b7e7d6fd5cde5b42761f073d6f1ffb2f32d6da88 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 30 Apr 2020 20:42:20 +0200 Subject: [PATCH] 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. --- common/dialogs/dialog_configure_paths.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/common/dialogs/dialog_configure_paths.cpp b/common/dialogs/dialog_configure_paths.cpp index 7ace4e6346..fc7e1e2350 100644 --- a/common/dialogs/dialog_configure_paths.cpp +++ b/common/dialogs/dialog_configure_paths.cpp @@ -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->DeleteRows( curRow, 1 ); - m_SearchPaths->MakeCellVisible( std::max( 0, curRow-1 ), m_SearchPaths->GetGridCursorCol() ); - m_SearchPaths->SetGridCursor( std::max( 0, curRow-1 ), m_SearchPaths->GetGridCursorCol() ); + // if there are still rows in grid, make previous row visible + 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() ); + } }