]> git.saurik.com Git - wxWidgets.git/commitdiff
Destroy correct HWND in wxMSW wxSpinCtrl::Reparent().
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 31 Oct 2010 11:37:26 +0000 (11:37 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 31 Oct 2010 11:37:26 +0000 (11:37 +0000)
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

index 1ca1b0528b5721a636b8c634f1b2b4efb8f096f7..bf6bd967555825f3cab3fdd493f47791377ce124 100644 (file)
@@ -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"));
     }