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)