Merge branch 'grid-refresh-block'
Avoid asserts due to passing invalid coordinates to RefreshBlock() when the grid didn't have any rows or columns. Closes https://github.com/wxWidgets/wxWidgets/pull/1725 Closes #18659, #18660.
This commit is contained in:
@@ -257,7 +257,7 @@ void wxGridSelection::SelectRow(int row, const wxKeyboardState& kbd)
|
||||
}
|
||||
|
||||
// Update View:
|
||||
if ( !m_grid->GetBatchCount() )
|
||||
if ( !m_grid->GetBatchCount() && m_grid->GetNumberCols() != 0 )
|
||||
{
|
||||
m_grid->RefreshBlock(row, 0, row, m_grid->GetNumberCols() - 1);
|
||||
}
|
||||
@@ -349,7 +349,7 @@ void wxGridSelection::SelectCol(int col, const wxKeyboardState& kbd)
|
||||
}
|
||||
|
||||
// Update View:
|
||||
if ( !m_grid->GetBatchCount() )
|
||||
if ( !m_grid->GetBatchCount() && m_grid->GetNumberRows() != 0 )
|
||||
{
|
||||
m_grid->RefreshBlock(0, col, m_grid->GetNumberRows() - 1, col);
|
||||
}
|
||||
|
@@ -73,6 +73,7 @@ private:
|
||||
WXUISIM_TEST( RangeSelect );
|
||||
CPPUNIT_TEST( Cursor );
|
||||
CPPUNIT_TEST( Selection );
|
||||
CPPUNIT_TEST( SelectEmptyGrid );
|
||||
CPPUNIT_TEST( ScrollWhenSelect );
|
||||
WXUISIM_TEST( MoveGridCursorUsingEndKey );
|
||||
WXUISIM_TEST( SelectUsingEndKey );
|
||||
@@ -117,6 +118,7 @@ private:
|
||||
void RangeSelect();
|
||||
void Cursor();
|
||||
void Selection();
|
||||
void SelectEmptyGrid();
|
||||
void ScrollWhenSelect();
|
||||
void MoveGridCursorUsingEndKey();
|
||||
void SelectUsingEndKey();
|
||||
@@ -600,6 +602,46 @@ void GridTestCase::Selection()
|
||||
CPPUNIT_ASSERT(!m_grid->IsInSelection(3, 0));
|
||||
}
|
||||
|
||||
void GridTestCase::SelectEmptyGrid()
|
||||
{
|
||||
SECTION("Delete rows/columns")
|
||||
{
|
||||
SECTION("No rows")
|
||||
{
|
||||
m_grid->DeleteRows(0, 10);
|
||||
REQUIRE( m_grid->GetNumberRows() == 0 );
|
||||
}
|
||||
SECTION("No columns")
|
||||
{
|
||||
m_grid->DeleteCols(0, 2);
|
||||
REQUIRE( m_grid->GetNumberCols() == 0 );
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("Select")
|
||||
{
|
||||
SECTION("Move right")
|
||||
{
|
||||
m_grid->MoveCursorRight(true);
|
||||
}
|
||||
SECTION("Move down")
|
||||
{
|
||||
m_grid->MoveCursorDown(true);
|
||||
}
|
||||
SECTION("Select row")
|
||||
{
|
||||
m_grid->SelectRow(1);
|
||||
}
|
||||
SECTION("Select column")
|
||||
{
|
||||
m_grid->SelectCol(1);
|
||||
}
|
||||
}
|
||||
|
||||
CHECK( m_grid->GetSelectionBlockTopLeft().Count() == 0 );
|
||||
CHECK( m_grid->GetSelectionBlockBottomRight().Count() == 0 );
|
||||
}
|
||||
|
||||
void GridTestCase::ScrollWhenSelect()
|
||||
{
|
||||
m_grid->AppendCols(10);
|
||||
|
Reference in New Issue
Block a user