]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix crash in wxStaticBox::HandleEraseBkgnd() in wxMSW on closing.
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 12 Jun 2012 21:56:58 +0000 (21:56 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 12 Jun 2012 21:56:58 +0000 (21:56 +0000)
Don't process WM_ERASEBKGND if we're being destroyed. This is at best useful
and at worst harmful as we currently crash in wxStaticBox::GetClientSize() if
there is no valid TLW parent.

Closes #14355.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71730 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/window.cpp

index 9285777c3d686dacfabeb3929ae3c07a5902e938..441e2584154e95c5b669bbe4e06a7689e571f830 100644 (file)
@@ -4843,6 +4843,16 @@ void wxWindowMSW::OnPaint(wxPaintEvent& event)
 
 bool wxWindowMSW::HandleEraseBkgnd(WXHDC hdc)
 {
+    if ( IsBeingDeleted() )
+    {
+        // We can get WM_ERASEBKGND after starting the destruction of our top
+        // level parent. Handling it in this case is unnecessary and can be
+        // actually harmful as e.g. wxStaticBox::GetClientSize() doesn't work
+        // without a valid TLW parent (because it uses dialog units internally
+        // which use the dialog font), so just don't do anything then.
+        return false;
+    }
+
     switch ( GetBackgroundStyle() )
     {
         case wxBG_STYLE_ERASE: