From: Robert Roebling Date: Tue, 27 May 2008 09:26:09 +0000 (+0000) Subject: Use wxList::DeleteContents() to delete columns X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/ef11ea71bb3d1213bb3355a5674fdec3d8d41514 Use wxList::DeleteContents() to delete columns git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53776 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/gtk/dataview.cpp b/src/gtk/dataview.cpp index c80f8bd012..dcaa4c1af9 100644 --- a/src/gtk/dataview.cpp +++ b/src/gtk/dataview.cpp @@ -3572,6 +3572,8 @@ wxDataViewCtrl::~wxDataViewCtrl() if (m_notifier) GetModel()->RemoveNotifier( m_notifier ); + m_cols.Clear(); + // remove the model from the GtkTreeView before it gets destroyed by the // wxDataViewCtrlBase's dtor gtk_tree_view_set_model( GTK_TREE_VIEW(m_treeview), NULL ); @@ -3583,6 +3585,8 @@ void wxDataViewCtrl::Init() { m_notifier = NULL; m_internal = NULL; + + m_cols.DeleteContents( true ); } static GtkTargetEntry gs_target; @@ -3817,7 +3821,7 @@ wxDataViewColumn* wxDataViewCtrl::GetColumn( unsigned int pos ) const return NULL; wxDataViewColumnList::const_iterator iter; - for (iter = m_cols.begin(); iter != m_cols.end(); iter++) + for (iter = m_cols.begin(); iter != m_cols.end(); ++iter) { wxDataViewColumn *col = *iter; if (GTK_TREE_VIEW_COLUMN(col->GetGtkHandle()) == gtk_col) @@ -3834,9 +3838,7 @@ bool wxDataViewCtrl::DeleteColumn( wxDataViewColumn *column ) gtk_tree_view_remove_column( GTK_TREE_VIEW(m_treeview), GTK_TREE_VIEW_COLUMN(column->GetGtkHandle()) ); - m_cols.remove( column ); - - delete column; + m_cols.DeleteObject( column ); return true; } @@ -3844,14 +3846,14 @@ bool wxDataViewCtrl::DeleteColumn( wxDataViewColumn *column ) bool wxDataViewCtrl::ClearColumns() { wxDataViewColumnList::iterator iter; - for (iter = m_cols.begin(); iter != m_cols.end(); iter++) + for (iter = m_cols.begin(); iter != m_cols.end(); ++iter) { wxDataViewColumn *col = *iter; gtk_tree_view_remove_column( GTK_TREE_VIEW(m_treeview), GTK_TREE_VIEW_COLUMN(col->GetGtkHandle()) ); } - m_cols.clear(); + m_cols.Clear(); return true; }