From 373a4816d447cbf6da448e139cd577599c866e86 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Mon, 8 Aug 2011 10:23:19 +0000 Subject: [PATCH] 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 --- src/generic/datavgen.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) 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 ) -- 2.45.2