From 36e9576d4216e40c2b7a979a7a3f8a610895744d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 6 Aug 2021 21:01:18 +0200 Subject: [PATCH] Fix not refreshing wxListCtrl properly under macOS Refresh() called from inside wxEVT_PAINT handler doesn't seem to have any effect, so use CallAfter() to call it slightly later instead. Closes #19139. --- src/generic/listctrl.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index 3ba6b9576c..8e903e6772 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -2058,7 +2058,19 @@ void wxListMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) ) } if ( m_dirty ) - RecalculatePositions( false ); + { + // Calling Refresh() from inside OnPaint() doesn't work under macOS, so + // don't do it immediately... + RecalculatePositions(true /* no refresh */); + + // ... but schedule it for later. + CallAfter(&wxWindow::Refresh, true, (const wxRect*)NULL); + + // Don't bother redoing the relayout again the next time nor redrawing + // now, as we'll be refresh soon anyhow. + m_dirty = false; + return; + } GetListCtrl()->PrepareDC( dc );