]> git.saurik.com Git - wxWidgets.git/commitdiff
Remove the item before notifying about it in wxDataViewIndexListModel.
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 12 Dec 2011 13:08:46 +0000 (13:08 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 12 Dec 2011 13:08:46 +0000 (13:08 +0000)
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

index 1dde0aadd153b313137b650f282fa11a8a4bcaec..febc1d1bf4674790497fdd257280e5e6e07ebe0c 100644 (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 )