From c59ed10c2ae9337a71f302483bc3f1a7c526539d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 24 Jun 2021 14:40:35 +0100 Subject: [PATCH] Fix DPI change handling in wxGrid with hidden row/column labels Don't reset the labels windows size to the default value, it should stay as 0 because otherwise we break the invariants m_rowLabelWidth != 0 <=> m_rowLabelWin->IsShown() m_colLabelHeight != 0 <=> m_colLabelWin->IsShown() that the rest of the code relies on. Closes #18904. --- src/generic/grid.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 362f4d242d..a487162a5e 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -2829,8 +2829,13 @@ void wxGrid::InitPixelFields() m_defaultRowHeight += 4; #endif - m_rowLabelWidth = FromDIP(WXGRID_DEFAULT_ROW_LABEL_WIDTH); - m_colLabelHeight = FromDIP(WXGRID_DEFAULT_COL_LABEL_HEIGHT); + // Don't change the value when called from OnDPIChanged() later if the + // corresponding label window is hidden, these values should remain zeroes + // then. + if ( m_rowLabelWin->IsShown() ) + m_rowLabelWidth = FromDIP(WXGRID_DEFAULT_ROW_LABEL_WIDTH); + if ( m_colLabelWin->IsShown() ) + m_colLabelHeight = FromDIP(WXGRID_DEFAULT_COL_LABEL_HEIGHT); m_defaultColWidth = FromDIP(WXGRID_DEFAULT_COL_WIDTH);