throw away the now invalid items in wxSelectionStore::SetItemCount() (bug 1929823) and added a unit test for this class

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52939 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-03-31 15:22:10 +00:00
parent d497bc6561
commit c8f80d2758
12 changed files with 187 additions and 7 deletions

View File

@@ -214,3 +214,19 @@ void wxSelectionStore::OnItemDelete(unsigned item)
}
}
void wxSelectionStore::SetItemCount(unsigned count)
{
// forget about all items whose indices are now invalid if the size
// decreased
if ( count < m_count )
{
for ( size_t i = m_itemsSel.GetCount(); i > 0; i-- )
{
if ( m_itemsSel[i - 1] >= count )
m_itemsSel.RemoveAt(i - 1);
}
}
// remember the new number of items
m_count = count;
}