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
virtual wxDataViewItem DoGetCurrentItem() const;
virtual void DoSetCurrentItem(const wxDataViewItem& item);
virtual wxDataViewItem DoGetCurrentItem() const;
virtual void DoSetCurrentItem(const wxDataViewItem& item);
+ // Return wxDataViewColumn matching the given GtkTreeViewColumn.
+ //
+ // If the input argument is NULL, return NULL too. Otherwise we must find
+ // the matching column and assert if we didn't.
+ wxDataViewColumn* FromGTKColumn(GtkTreeViewColumn *gtk_col) const;
+
friend class wxDataViewCtrlDCImpl;
friend class wxDataViewColumn;
friend class wxDataViewCtrlInternal;
friend class wxDataViewCtrlDCImpl;
friend class wxDataViewColumn;
friend class wxDataViewCtrlInternal;
void wxDataViewRendererBase::DestroyEditControl()
{
void wxDataViewRendererBase::DestroyEditControl()
{
+ // Remove our event handler first to prevent it from (recursively) calling
+ // us again as it would do via a call to FinishEditing() when the editor
+ // loses focus when we hide it below.
+ wxEvtHandler * const handler = m_editorCtrl->PopEventHandler();
+
// Hide the control immediately but don't delete it yet as there could be
// some pending messages for it.
m_editorCtrl->Hide();
// Hide the control immediately but don't delete it yet as there could be
// some pending messages for it.
m_editorCtrl->Hide();
- wxEvtHandler * const handler = m_editorCtrl->PopEventHandler();
-
wxPendingDelete.Append(handler);
wxPendingDelete.Append(m_editorCtrl);
}
wxPendingDelete.Append(handler);
wxPendingDelete.Append(m_editorCtrl);
}
if (!m_editorCtrl)
return;
if (!m_editorCtrl)
return;
- GetOwner()->GetOwner()->GetMainWindow()->SetFocus();
-
wxDataViewCtrl::~wxDataViewCtrl()
{
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;
m_cols.Clear();
delete m_internal;
return m_cols.GetCount();
}
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)
return NULL;
wxDataViewColumnList::const_iterator iter;
return NULL;
wxDataViewColumnList::const_iterator iter;
+ wxFAIL_MSG( "No matching column?" );
+
+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),
bool wxDataViewCtrl::DeleteColumn( wxDataViewColumn *column )
{
gtk_tree_view_remove_column( GTK_TREE_VIEW(m_treeview),