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
This commit is contained in:
Václav Slavík
2011-08-08 10:23:19 +00:00
parent 04675edfb1
commit 373a4816d4

View File

@@ -4428,13 +4428,23 @@ int wxDataViewCtrl::GetSelections( wxDataViewItemArray & sel ) const
{ {
sel.Empty(); sel.Empty();
wxDataViewSelection selection = m_clientArea->GetSelections(); 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]; wxDataViewItem item = m_clientArea->GetItemByRow(*i);
sel.Add( m_clientArea->GetItemByRow( row ) ); 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 ) void wxDataViewCtrl::SetSelections( const wxDataViewItemArray & sel )