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
This commit is contained in:
Vadim Zeitlin
2011-12-12 13:08:46 +00:00
parent 46e9b34a60
commit d4cf50c8b2

View File

@@ -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 )