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
This commit is contained in:
Vadim Zeitlin
2008-05-30 00:03:03 +00:00
parent 3877c17eeb
commit 5cd4cb75ee
2 changed files with 18 additions and 29 deletions

View File

@@ -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()

View File

@@ -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;
}
DeleteEditControl();
return true;
}