From b9d668e8f19b2af2f81d0765703103e5657e8931 Mon Sep 17 00:00:00 2001 From: Daniel Kulp Date: Sun, 28 Jul 2019 01:53:52 +0200 Subject: [PATCH] Fix recently introduced crash during wxGrid initialization CellToGridWindow(), added by frozen rows/columns patch, returned NULL when called with invalid row/col arguments and this could happen if any of several methods using m_currentCellCoords were called during wxGrid initialization, while m_currentCellCoords was still (-1, -1). Fix this by testing for this case explicitly and returning the main grid window, which is never NULL, instead. Closes #18454. --- src/generic/grid.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 6fb374a048..934e7a74bb 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -7323,7 +7323,12 @@ wxRect wxGrid::CellToRect( int row, int col ) const wxGridWindow* wxGrid::CellToGridWindow( int row, int col ) const { - if ( row < m_numFrozenRows && GetColPos(col) < m_numFrozenCols ) + // It may happen that we're called during grid creation, when the current + // cell still has invalid coordinates -- don't return (possibly null) + // frozen corner window in this case. + if ( row == -1 && col == -1 ) + return m_gridWin; + else if ( row < m_numFrozenRows && GetColPos(col) < m_numFrozenCols ) return m_frozenCornerGridWin; else if ( row < m_numFrozenRows ) return m_frozenRowGridWin;