From: Václav Slavík Date: Mon, 8 Aug 2011 10:23:19 +0000 (+0000) Subject: Check for invalid items in generic wxDataViewCtrl::GetSelections(). X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/373a4816d447cbf6da448e139cd577599c866e86 Check for invalid items in generic wxDataViewCtrl::GetSelections(). This shouldn't normally happen, but if some bug causes it, detect it. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68598 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 76c7344fea..4573c9bb78 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -4428,13 +4428,23 @@ int wxDataViewCtrl::GetSelections( wxDataViewItemArray & sel ) const { sel.Empty(); wxDataViewSelection selection = m_clientArea->GetSelections(); - int len = selection.GetCount(); - for( int i = 0; i < len; i ++) + + for ( wxDataViewSelection::const_iterator i = selection.begin(); + i != selection.end(); + ++i ) { - unsigned int row = selection[i]; - sel.Add( m_clientArea->GetItemByRow( row ) ); + wxDataViewItem item = m_clientArea->GetItemByRow(*i); + if ( item.IsOk() ) + { + sel.Add(item); + } + else + { + wxFAIL_MSG( "invalid item in selection - bad internal state" ); + } } - return len; + + return sel.size(); } void wxDataViewCtrl::SetSelections( const wxDataViewItemArray & sel )