Fix assert when destroying wxDataViewCtrl being edited in wxGTK.
If wxDataViewCtrl was destroyed while showing a generic editor, an assert occurred in wxWindowBase dtor as the event handler pushed on it by the editor. Fix this by calling CancelEditing() when the control is destroyed and also fix the crash in CancelEditing() in wxGTK due to recursive calls to FinishEditing(). Closes #12683. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67612 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -4447,6 +4447,22 @@ IMPLEMENT_DYNAMIC_CLASS(wxDataViewCtrl, wxDataViewCtrlBase)
|
||||
|
||||
wxDataViewCtrl::~wxDataViewCtrl()
|
||||
{
|
||||
// Stop editing before destroying the control to remove any event handlers
|
||||
// which are added when editing started: if we didn't do this, the base
|
||||
// class dtor would assert as it checks for any leftover handlers.
|
||||
if ( m_treeview )
|
||||
{
|
||||
GtkTreeViewColumn *col;
|
||||
gtk_tree_view_get_cursor(GTK_TREE_VIEW(m_treeview), NULL, &col);
|
||||
|
||||
wxDataViewColumn * const wxcol = FromGTKColumn(col);
|
||||
if ( wxcol )
|
||||
{
|
||||
// This won't do anything if we're not editing it
|
||||
wxcol->GetRenderer()->CancelEditing();
|
||||
}
|
||||
}
|
||||
|
||||
m_cols.Clear();
|
||||
|
||||
delete m_internal;
|
||||
@@ -4689,10 +4705,9 @@ unsigned int wxDataViewCtrl::GetColumnCount() const
|
||||
return m_cols.GetCount();
|
||||
}
|
||||
|
||||
wxDataViewColumn* wxDataViewCtrl::GetColumn( unsigned int pos ) const
|
||||
wxDataViewColumn* wxDataViewCtrl::FromGTKColumn(GtkTreeViewColumn *gtk_col) const
|
||||
{
|
||||
GtkTreeViewColumn *gtk_col = gtk_tree_view_get_column( GTK_TREE_VIEW(m_treeview), pos );
|
||||
if (!gtk_col)
|
||||
if ( !gtk_col )
|
||||
return NULL;
|
||||
|
||||
wxDataViewColumnList::const_iterator iter;
|
||||
@@ -4705,9 +4720,18 @@ wxDataViewColumn* wxDataViewCtrl::GetColumn( unsigned int pos ) const
|
||||
}
|
||||
}
|
||||
|
||||
wxFAIL_MSG( "No matching column?" );
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
wxDataViewColumn* wxDataViewCtrl::GetColumn( unsigned int pos ) const
|
||||
{
|
||||
GtkTreeViewColumn *gtk_col = gtk_tree_view_get_column( GTK_TREE_VIEW(m_treeview), pos );
|
||||
|
||||
return FromGTKColumn(gtk_col);
|
||||
}
|
||||
|
||||
bool wxDataViewCtrl::DeleteColumn( wxDataViewColumn *column )
|
||||
{
|
||||
gtk_tree_view_remove_column( GTK_TREE_VIEW(m_treeview),
|
||||
|
Reference in New Issue
Block a user