diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 02cbeb0947..4d906a5c85 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -1841,7 +1841,19 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) wxConvertFromMSWListItem(NULL, event.m_item, item); if ( ((LV_ITEM)item).pszText == NULL || ((LV_ITEM)item).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; + } return FALSE; + } event.m_itemIndex = event.m_item.m_itemId; } @@ -1853,7 +1865,19 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) wxConvertFromMSWListItem(NULL, event.m_item, item); if ( ((LV_ITEM)item).pszText == NULL || ((LV_ITEM)item).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; + } return FALSE; + } event.m_itemIndex = event.m_item.m_itemId; }