From d3bc59e0e7912d4aa3a66161ec505b5be56cc770 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 24 Jan 2024 16:39:52 +0000 Subject: [PATCH] SelectBlock() will assert for invalid selection modes. KICAD-63D. --- common/widgets/wx_grid.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/common/widgets/wx_grid.cpp b/common/widgets/wx_grid.cpp index da903143d2..e2b78c150c 100644 --- a/common/widgets/wx_grid.cpp +++ b/common/widgets/wx_grid.cpp @@ -194,8 +194,22 @@ void WX_GRID::onGridCellSelect( wxGridEvent& aEvent ) int row = aEvent.GetRow(); int col = aEvent.GetCol(); - if( row >= 0 && col >= 0 ) - SelectBlock( row, col, row, col, false ); + if( row >= 0 && row < GetNumberRows() && col >= 0 && col < GetNumberCols() ) + { + if( GetSelectionMode() == wxGrid::wxGridSelectCells ) + { + SelectBlock( row, col, row, col, false ); + } + else if( GetSelectionMode() == wxGrid::wxGridSelectRows + || GetSelectionMode() == wxGrid::wxGridSelectRowsOrColumns ) + { + SelectBlock( row, 0, row, GetNumberCols() - 1, false ); + } + else if( GetSelectionMode() == wxGrid::wxGridSelectColumns ) + { + SelectBlock( 0, col, GetNumberRows() - 1, col, false ); + } + } }