From: Vadim Zeitlin Date: Fri, 30 May 2008 00:03:03 +0000 (+0000) Subject: no changes, just refactor the code to avoid having the same code for m_textCtrl destr... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/5cd4cb75ee776215a4de0f0af694b4334a0fd97b no changes, just refactor the code to avoid having the same code for m_textCtrl destruction in 4 places git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53830 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/msw/listctrl.h b/include/wx/msw/listctrl.h index 50b04f98be..635a0af233 100644 --- a/include/wx/msw/listctrl.h +++ b/include/wx/msw/listctrl.h @@ -446,6 +446,9 @@ private: // UpdateStyle()), only should be called if InReportView() void MSWSetExListStyles(); + // destroy m_textCtrl if it's currently valid and reset it to NULL + void DeleteEditControl(); + DECLARE_DYNAMIC_CLASS(wxListCtrl) DECLARE_EVENT_TABLE() diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index ab90123b9a..16cf30a914 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -488,10 +488,8 @@ void wxListCtrl::FreeAllInternalData() } } -wxListCtrl::~wxListCtrl() +void wxListCtrl::DeleteEditControl() { - FreeAllInternalData(); - if ( m_textCtrl ) { m_textCtrl->UnsubclassWin(); @@ -499,6 +497,13 @@ wxListCtrl::~wxListCtrl() delete m_textCtrl; m_textCtrl = NULL; } +} + +wxListCtrl::~wxListCtrl() +{ + FreeAllInternalData(); + + DeleteEditControl(); if (m_ownsImageListNormal) delete m_imageListNormal; @@ -1465,12 +1470,7 @@ wxTextCtrl* wxListCtrl::EditLabel(long item, wxClassInfo* textControlClass) } // [re]create the text control wrapping the HWND we got - if ( m_textCtrl ) - { - m_textCtrl->UnsubclassWin(); - m_textCtrl->SetHWND(0); - delete m_textCtrl; - } + DeleteEditControl(); m_textCtrl = (wxTextCtrl *)textControlClass->CreateObject(); m_textCtrl->SetHWND(hWnd); @@ -2093,16 +2093,9 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) const LV_ITEM& lvi = (LV_ITEM)item; if ( !lvi.pszText || lvi.iItem == -1 ) { - // don't keep a stale wxTextCtrl around - if ( m_textCtrl ) - { - // EDIT control will be deleted by the list control itself so - // prevent us from deleting it as well - m_textCtrl->UnsubclassWin(); - m_textCtrl->SetHWND(0); - delete m_textCtrl; - m_textCtrl = NULL; - } + // EDIT control will be deleted by the list control + // itself so prevent us from deleting it as well + DeleteEditControl(); event.SetEditCanceled(true); } @@ -2475,16 +2468,9 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) // logic here is inverted compared to all the other messages *result = event.IsAllowed(); - // don't keep a stale wxTextCtrl around - if ( m_textCtrl ) - { - // EDIT control will be deleted by the list control itself so - // prevent us from deleting it as well - m_textCtrl->UnsubclassWin(); - m_textCtrl->SetHWND(0); - delete m_textCtrl; - m_textCtrl = NULL; - } + // EDIT control will be deleted by the list control itself so + // prevent us from deleting it as well + DeleteEditControl(); return true; }