From 2d164de6e13a41d3caf8a8017a06b44f6ca6e28f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 6 Jun 2008 22:55:23 +0000 Subject: [PATCH] don't leave current item index invalid after SetItemCount() (ticket #3720) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@53998 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/vlbox.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/generic/vlbox.cpp b/src/generic/vlbox.cpp index 2a3ca54d1c..68e14a80fa 100644 --- a/src/generic/vlbox.cpp +++ b/src/generic/vlbox.cpp @@ -98,6 +98,10 @@ wxVListBox::~wxVListBox() void wxVListBox::SetItemCount(size_t count) { + // don't leave the current index invalid + if ( m_current != wxNOT_FOUND && (size_t)m_current >= count ) + m_current = count - 1; // also ok when count == 0 as wxNOT_FOUND == -1 + if ( m_selStore ) { // tell the selection store that our number of items has changed