From 00c497125e727154bc243b32813447c927d38ce7 Mon Sep 17 00:00:00 2001 From: Dimitri Schoolwerth Date: Tue, 19 Jan 2021 22:17:41 +0100 Subject: [PATCH] Fix drawing of grid cells appearing inside a multicell Grid cells are considered for redrawing solely based on having a (text) value. This can lead to infinite recursion with overflowing inside cells if wxGridCellStringRenderer::Draw() wants to draw cells appearing after this one but instead visits the same cell again (because of a negative cell size as opposed to expected default cell size of 1x1 or a larger spanning size) and calls DrawCell() again for this cell which will call the renderer's Draw() again etc... Fix by not taking inside cells into consideration for redrawing. This is the right thing to do as earlier on in the same function a cell is not drawn for the same reason. Also the aforementioned Draw() mentions it shouldn't be called for cell sizes <= 0. Also fixes the crashing grid test just introduced in 6d3dbc3fe5. --- src/generic/grid.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index f6b7244760..566f0a8102 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -6217,6 +6217,12 @@ void wxGrid::DrawGridCellArea( wxDC& dc, const wxGridCellCoordsArray& cells ) { if (!m_table->IsEmptyCell(row + l, j)) { + int numRows, numCols; + if ( GetCellSize(row + l, j, &numRows, &numCols) + == wxGrid::CellSpan_Inside ) + // As above: don't bother drawing inside cells. + continue; + if ( GetCellAttrPtr(row + l, j)->CanOverflow() ) { wxGridCellCoords cell(row + l, j);