]> git.saurik.com Git - wxWidgets.git/commitdiff
Don't iterate over selection twice needlessly in wxDataViewMainWindow::ItemDeleted().
authorVáclav Slavík <vslavik@fastmail.fm>
Mon, 22 Aug 2011 14:14:53 +0000 (14:14 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Mon, 22 Aug 2011 14:14:53 +0000 (14:14 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68846 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/generic/datavgen.cpp

index 9511f209d435cab5cd3edc107bdf176e97f75014..7cebed518a7dffea5a019ab1c4b2740e9804d1e0 100644 (file)
@@ -2023,16 +2023,19 @@ bool wxDataViewMainWindow::ItemDeleted(const wxDataViewItem& parent,
         {
             const int row = GetRowByItem(item);
 
+            int rowIndexInSelection = wxNOT_FOUND;
+
             const size_t selCount = m_selection.size();
             for ( size_t i = 0; i < selCount; i++ )
             {
-                if ( m_selection[i] > (unsigned)row )
+                if ( m_selection[i] == (unsigned)row )
+                    rowIndexInSelection = i;
+                else if ( m_selection[i] > (unsigned)row )
                     m_selection[i]--;
             }
 
-            int itemRow = m_selection.Index(row);
-            if ( itemRow != wxNOT_FOUND )
-                m_selection.RemoveAt(itemRow);
+            if ( rowIndexInSelection != wxNOT_FOUND )
+                m_selection.RemoveAt(rowIndexInSelection);
         }
 
     }