From 52b90aa7abd254ce774fa00fa9843a11a3d359d4 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 7 Jan 2008 18:43:23 +0000 Subject: [PATCH] check that HWNDs are non-NULL before doing anything with them (part of patch 1866053) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51077 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/subwin.h | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/include/wx/msw/subwin.h b/include/wx/msw/subwin.h index cbe712e73c..06ba1433e5 100644 --- a/include/wx/msw/subwin.h +++ b/include/wx/msw/subwin.h @@ -40,7 +40,8 @@ public: { for ( size_t n = 0; n < m_count; n++ ) { - ::DestroyWindow(m_hwnds[n]); + if ( m_hwnds[n] ) + ::DestroyWindow(m_hwnds[n]); } free(m_hwnds); @@ -95,7 +96,8 @@ public: int sw = show ? SW_SHOW : SW_HIDE; for ( size_t n = 0; n < m_count; n++ ) { - ::ShowWindow(m_hwnds[n], sw); + if ( m_hwnds[n] ) + ::ShowWindow(m_hwnds[n], sw); } } @@ -104,7 +106,8 @@ public: { for ( size_t n = 0; n < m_count; n++ ) { - ::EnableWindow(m_hwnds[n], enable); + if ( m_hwnds[n] ) + ::EnableWindow(m_hwnds[n], enable); } } @@ -116,10 +119,13 @@ public: for ( size_t n = 0; n < m_count; n++ ) { - ::SendMessage(m_hwnds[n], WM_SETFONT, (WPARAM)hfont, 0); + if ( m_hwnds[n] ) + { + ::SendMessage(m_hwnds[n], WM_SETFONT, (WPARAM)hfont, 0); - // otherwise the window might not be redrawn correctly - ::InvalidateRect(m_hwnds[n], NULL, FALSE /* don't erase bg */); + // otherwise the window might not be redrawn correctly + ::InvalidateRect(m_hwnds[n], NULL, FALSE /* don't erase bg */); + } } } @@ -129,10 +135,14 @@ public: wxRect r; for ( size_t n = 0; n < m_count; n++ ) { - RECT rc; - ::GetWindowRect(m_hwnds[n], &rc); + if ( m_hwnds[n] ) + { + RECT rc; - r.Union(wxRectFromRECT(rc)); + ::GetWindowRect(m_hwnds[n], &rc); + + r.Union(wxRectFromRECT(rc)); + } } return r; -- 2.45.2