From d4cf50c8b2574caec6dc13f7dfb0f3ee2b92842e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 12 Dec 2011 13:08:46 +0000 Subject: [PATCH] Remove the item before notifying about it in wxDataViewIndexListModel. Remove the item from the internal representation of the model before calling ItemDeleted() callback so that the callback sees the model in a consistent state. This is more consistent with the other callbacks (e.g. ItemAdded()) and other models (e.g. wxDataViewVirtualListModel) and should fix crashes in wxOSX version of the control. Closes #13753. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69990 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/datavcmn.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/common/datavcmn.cpp b/src/common/datavcmn.cpp index 1dde0aadd1..febc1d1bf4 100644 --- a/src/common/datavcmn.cpp +++ b/src/common/datavcmn.cpp @@ -451,15 +451,12 @@ void wxDataViewIndexListModel::RowDeleted( unsigned int row ) m_ordered = false; wxDataViewItem item( m_hash[row] ); - /* wxDataViewModel:: */ ItemDeleted( wxDataViewItem(0), item ); m_hash.RemoveAt( row ); + /* wxDataViewModel:: */ ItemDeleted( wxDataViewItem(0), item ); } void wxDataViewIndexListModel::RowsDeleted( const wxArrayInt &rows ) { - wxArrayInt sorted = rows; - sorted.Sort( my_sort ); - m_ordered = false; wxDataViewItemArray array; @@ -469,10 +466,13 @@ void wxDataViewIndexListModel::RowsDeleted( const wxArrayInt &rows ) wxDataViewItem item( m_hash[rows[i]] ); array.Add( item ); } - /* wxDataViewModel:: */ ItemsDeleted( wxDataViewItem(0), array ); + wxArrayInt sorted = rows; + sorted.Sort( my_sort ); for (i = 0; i < sorted.GetCount(); i++) m_hash.RemoveAt( sorted[i] ); + + /* wxDataViewModel:: */ ItemsDeleted( wxDataViewItem(0), array ); } void wxDataViewIndexListModel::RowChanged( unsigned int row ) -- 2.47.2