From 55c5be5e47fc43429d5004d99a133eb6b4475417 Mon Sep 17 00:00:00 2001 From: David Elliott Date: Wed, 9 Jul 2003 14:24:47 +0000 Subject: [PATCH] Avoid paint event recursion when the run loop is restarted inside the paint event. Usually for the purpose of showing an assertion dialog. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21794 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/cocoa/window.h | 1 + src/cocoa/window.mm | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/wx/cocoa/window.h b/include/wx/cocoa/window.h index 71ff892724..94cf3e1a85 100644 --- a/include/wx/cocoa/window.h +++ b/include/wx/cocoa/window.h @@ -72,6 +72,7 @@ protected: void SetNSView(WX_NSView cocoaNSView); WX_NSView m_cocoaNSView; WX_NSView m_dummyNSView; + bool m_isInPaint; // ------------------------------------------------------------------------ // Implementation // ------------------------------------------------------------------------ diff --git a/src/cocoa/window.mm b/src/cocoa/window.mm index d32720d412..5666a121ac 100644 --- a/src/cocoa/window.mm +++ b/src/cocoa/window.mm @@ -33,6 +33,7 @@ void wxWindowCocoa::Init() m_cocoaNSView = NULL; m_dummyNSView = NULL; m_isBeingDeleted = FALSE; + m_isInPaint = FALSE; } // Constructor @@ -120,10 +121,21 @@ void wxWindowCocoa::SetNSView(WX_NSView cocoaNSView) bool wxWindowCocoa::Cocoa_drawRect(const NSRect &rect) { wxLogDebug("Cocoa_drawRect"); + // Recursion can happen if the event loop runs from within the paint + // handler. For instance, if an assertion dialog is shown. + // FIXME: This seems less than ideal. + if(m_isInPaint) + { + wxLogDebug("Paint event recursion!"); + return false; + } //FIXME: should probably turn that rect into the update region + m_isInPaint = TRUE; wxPaintEvent event(m_windowId); event.SetEventObject(this); - return GetEventHandler()->ProcessEvent(event); + bool ret = GetEventHandler()->ProcessEvent(event); + m_isInPaint = FALSE; + return ret; } void wxWindowCocoa::InitMouseEvent(wxMouseEvent& event, WX_NSEvent cocoaEvent) -- 2.50.0