]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/erase/erase.cpp
fixes potential crash under gatekeeper
[wxWidgets.git] / samples / erase / erase.cpp
index 96e21c3b6fbd9c4211b077f18ee1735e863d7973..37fc81bb8870ddcdf4a444b02bde67e89b951343 100644 (file)
@@ -362,10 +362,16 @@ MyCanvas::MyCanvas(wxFrame *parent)
 
 void MyCanvas::DoPaint(wxDC& dc)
 {
+    PrepareDC(dc);
+
     if ( m_eraseBgInPaint )
     {
         dc.SetBackground(*wxLIGHT_GREY);
-        dc.Clear();
+
+        // Erase the entire virtual area, not just the client area.
+        dc.SetPen(*wxTRANSPARENT_PEN);
+        dc.SetBrush(GetBackgroundColour());
+        dc.DrawRectangle(GetVirtualSize());
 
         dc.DrawText("Background erased in OnPaint", 65, 110);
     }
@@ -387,15 +393,11 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
     if ( m_useBuffer )
     {
         wxAutoBufferedPaintDC dc(this);
-        PrepareDC(dc);
-
         DoPaint(dc);
     }
     else
     {
         wxPaintDC dc(this);
-        PrepareDC(dc);
-
         DoPaint(dc);
     }
 }