From 4261e1d07d52c0703a5adf4a436937eb0f8896e2 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 13 Feb 2024 01:00:48 +0100 Subject: [PATCH] Erase overlay contents when resetting it in wxOSX Without this, the old contents continues to be shown for some time before the display was refreshed. --- src/osx/cocoa/overlay.mm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/osx/cocoa/overlay.mm b/src/osx/cocoa/overlay.mm index c8a8e9fe28..6452e6026c 100644 --- a/src/osx/cocoa/overlay.mm +++ b/src/osx/cocoa/overlay.mm @@ -157,6 +157,11 @@ wxOverlay::Impl* wxOverlay::Create() wxOverlayImpl::~wxOverlayImpl() { + // Set it to null before calling Reset() to prevent it from drawing + // anything: this is not needed when destroying the overlay and would + // result in problems. + m_window = nullptr; + Reset(); } @@ -275,6 +280,15 @@ void wxOverlayImpl::Clear(wxDC* dc) void wxOverlayImpl::Reset() { + if ( m_window ) + { + // erase whatever was drawn on the overlay the last time + wxClientDC dc(m_window); + BeginDrawing(&dc); + Clear(&dc); + EndDrawing(&dc); + } + if ( m_overlayContext ) { [(id)m_overlayContext release];