From a15781955d5e06b1a9a197be87a6f8734a8ba5e2 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 12 Jun 2012 21:56:58 +0000 Subject: [PATCH] Fix crash in wxStaticBox::HandleEraseBkgnd() in wxMSW on closing. 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 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 9285777c3d..441e258415 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -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: -- 2.45.2