Fix wrong wxGrid::RefreshBlock calling for an empty grid

There is no cells to select if the grid is empty (no rows or no columns).
So check for the columns count in SelectRow and check for the rows count in
SelectCol and call RefreshBlock only if it necessary.

Fix https://trac.wxwidgets.org/ticket/18659
Fix https://trac.wxwidgets.org/ticket/18660
This commit is contained in:
Ilya Sinitsyn
2020-02-03 18:09:47 +07:00
parent 360bbbc453
commit 0c9a9dc126

View File

@@ -257,7 +257,7 @@ void wxGridSelection::SelectRow(int row, const wxKeyboardState& kbd)
} }
// Update View: // Update View:
if ( !m_grid->GetBatchCount() ) if ( !m_grid->GetBatchCount() && m_grid->GetNumberCols() != 0 )
{ {
m_grid->RefreshBlock(row, 0, row, m_grid->GetNumberCols() - 1); m_grid->RefreshBlock(row, 0, row, m_grid->GetNumberCols() - 1);
} }
@@ -349,7 +349,7 @@ void wxGridSelection::SelectCol(int col, const wxKeyboardState& kbd)
} }
// Update View: // Update View:
if ( !m_grid->GetBatchCount() ) if ( !m_grid->GetBatchCount() && m_grid->GetNumberRows() != 0 )
{ {
m_grid->RefreshBlock(0, col, m_grid->GetNumberRows() - 1, col); m_grid->RefreshBlock(0, col, m_grid->GetNumberRows() - 1, col);
} }