Destroy the in-place edit control in wxGenericListCtrl dtor.
If the in-place text control was still alive when wxGenericListCtrl was destroyed, it resulted in asserts from wxWindow dtor about child windows still being alive, so explicitly destroy it from wxListMainWindow dtor. As this required a slightly different behaviour from wxListTextCtrlWrapper:: EndEdit(), replace its bool argument with an enum one which can take more than 2 values. Not using bool values when calling it also made the code more clear. Finally, added a unit test verifying that the in-place control is indeed destroyed correctly. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65769 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1407,23 +1407,31 @@ wxListTextCtrlWrapper::wxListTextCtrlWrapper(wxListMainWindow *owner,
|
||||
m_text->PushEventHandler(this);
|
||||
}
|
||||
|
||||
void wxListTextCtrlWrapper::EndEdit(bool discardChanges)
|
||||
void wxListTextCtrlWrapper::EndEdit(EndReason reason)
|
||||
{
|
||||
m_aboutToFinish = true;
|
||||
|
||||
if ( discardChanges )
|
||||
switch ( reason )
|
||||
{
|
||||
m_owner->OnRenameCancelled(m_itemEdited);
|
||||
case End_Accept:
|
||||
// Notify the owner about the changes
|
||||
AcceptChanges();
|
||||
|
||||
Finish( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Notify the owner about the changes
|
||||
AcceptChanges();
|
||||
// Even if vetoed, close the control (consistent with MSW)
|
||||
Finish( true );
|
||||
break;
|
||||
|
||||
// Even if vetoed, close the control (consistent with MSW)
|
||||
Finish( true );
|
||||
case End_Discard:
|
||||
m_owner->OnRenameCancelled(m_itemEdited);
|
||||
|
||||
Finish( true );
|
||||
break;
|
||||
|
||||
case End_Destroy:
|
||||
// Don't generate any notifications for the control being destroyed
|
||||
// and don't set focus to it neither.
|
||||
Finish(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1462,11 +1470,11 @@ void wxListTextCtrlWrapper::OnChar( wxKeyEvent &event )
|
||||
switch ( event.m_keyCode )
|
||||
{
|
||||
case WXK_RETURN:
|
||||
EndEdit( false );
|
||||
EndEdit( End_Accept );
|
||||
break;
|
||||
|
||||
case WXK_ESCAPE:
|
||||
EndEdit( true );
|
||||
EndEdit( End_Discard );
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -1600,6 +1608,9 @@ wxListMainWindow::wxListMainWindow( wxWindow *parent,
|
||||
|
||||
wxListMainWindow::~wxListMainWindow()
|
||||
{
|
||||
if ( m_textctrlWrapper )
|
||||
m_textctrlWrapper->EndEdit(wxListTextCtrlWrapper::End_Destroy);
|
||||
|
||||
DoDeleteAllItems();
|
||||
WX_CLEAR_LIST(wxListHeaderDataList, m_columns);
|
||||
WX_CLEAR_ARRAY(m_aColWidths);
|
||||
@@ -2273,7 +2284,7 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event )
|
||||
// listctrl because the order of events is different (or something like
|
||||
// that), so explicitly end the edit if it is active.
|
||||
if ( event.LeftDown() && m_textctrlWrapper )
|
||||
m_textctrlWrapper->EndEdit( false );
|
||||
m_textctrlWrapper->EndEdit(wxListTextCtrlWrapper::End_Accept);
|
||||
#endif // __WXMAC__
|
||||
|
||||
if ( event.LeftDown() )
|
||||
|
Reference in New Issue
Block a user