From bc73fe96a2ba3e72338de7579f4b27c9f11a2fc3 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 31 Oct 2010 11:37:26 +0000 Subject: [PATCH] Destroy correct HWND in wxMSW wxSpinCtrl::Reparent(). NULL HWND was passed to ::DestroyWindow() as wxWindow::UnsubclassWin() NULLed it after unsubclassing. See #12633. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65965 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/spinctrl.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/msw/spinctrl.cpp b/src/msw/spinctrl.cpp index 1ca1b0528b..bf6bd96755 100644 --- a/src/msw/spinctrl.cpp +++ b/src/msw/spinctrl.cpp @@ -604,9 +604,11 @@ bool wxSpinCtrl::Reparent(wxWindowBase *newParent) int value = GetValue(); const wxRect btnRect = wxRectFromRECT(wxGetWindowRect(GetHwnd())); - // destroy the old spin button + // destroy the old spin button after detaching it from this wxWindow object + // (notice that m_hWnd will be reset by UnsubclassWin() so save it first) + const HWND hwndOld = GetHwnd(); UnsubclassWin(); - if ( !::DestroyWindow(GetHwnd()) ) + if ( !::DestroyWindow(hwndOld) ) { wxLogLastError(wxT("DestroyWindow")); } -- 2.45.2