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];