From 1671a21e7c4d2bf4d4286907912c271dfa08bcb8 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 27 Apr 2021 13:58:49 +0200 Subject: [PATCH] Fix crash when scrolling wxGrid in which scrolling is disabled If "pixels per line" is set to 0, indicating that scrolling is disabled, just don't scroll in the corresponding direction instead of dividing by zero. Closes https://github.com/wxWidgets/wxWidgets/pull/2323 --- src/generic/grid.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 41fd4524cf..41a11ccda6 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -8099,8 +8099,9 @@ void wxGrid::MakeCellVisible( int row, int col ) col < -1 || col >= m_numCols ) return; - const bool processRow = row != -1; - const bool processCol = col != -1; + // We don't scroll in the corresponding direction if "pixels per line" is 0. + const bool processRow = row != -1 && m_yScrollPixelsPerLine != 0; + const bool processCol = col != -1 && m_xScrollPixelsPerLine != 0; // Get the cell rectangle in logical coords. wxRect r;