]> git.saurik.com Git - wxWidgets.git/commitdiff
Avoid paint event recursion when the run loop is restarted inside the paint
authorDavid Elliott <dfe@tgwbd.org>
Wed, 9 Jul 2003 14:24:47 +0000 (14:24 +0000)
committerDavid Elliott <dfe@tgwbd.org>
Wed, 9 Jul 2003 14:24:47 +0000 (14:24 +0000)
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
src/cocoa/window.mm

index 71ff892724ea167ec4fcbe5b858a8308e29500b7..94cf3e1a85763b83cdf0964a8ac54061b77eb3e0 100644 (file)
@@ -72,6 +72,7 @@ protected:
     void SetNSView(WX_NSView cocoaNSView);
     WX_NSView m_cocoaNSView;
     WX_NSView m_dummyNSView;
     void SetNSView(WX_NSView cocoaNSView);
     WX_NSView m_cocoaNSView;
     WX_NSView m_dummyNSView;
+    bool m_isInPaint;
 // ------------------------------------------------------------------------
 // Implementation
 // ------------------------------------------------------------------------
 // ------------------------------------------------------------------------
 // Implementation
 // ------------------------------------------------------------------------
index d32720d412a68f8f767e37d3411a468bca1c8a08..5666a121ac7248632928f2b9b91f387f39823552 100644 (file)
@@ -33,6 +33,7 @@ void wxWindowCocoa::Init()
     m_cocoaNSView = NULL;
     m_dummyNSView = NULL;
     m_isBeingDeleted = FALSE;
     m_cocoaNSView = NULL;
     m_dummyNSView = NULL;
     m_isBeingDeleted = FALSE;
+    m_isInPaint = FALSE;
 }
 
 // Constructor
 }
 
 // Constructor
@@ -120,10 +121,21 @@ void wxWindowCocoa::SetNSView(WX_NSView cocoaNSView)
 bool wxWindowCocoa::Cocoa_drawRect(const NSRect &rect)
 {
     wxLogDebug("Cocoa_drawRect");
 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
     //FIXME: should probably turn that rect into the update region
+    m_isInPaint = TRUE;
     wxPaintEvent event(m_windowId);
     event.SetEventObject(this);
     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)
 }
 
 void wxWindowCocoa::InitMouseEvent(wxMouseEvent& event, WX_NSEvent cocoaEvent)