From: Vadim Zeitlin Date: Fri, 6 Jun 2008 22:55:23 +0000 (+0000) Subject: don't leave current item index invalid after SetItemCount() (ticket #3720) X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/9543d01ca16af6171735db4fc78e2dc7f9d4065c don't leave current item index invalid after SetItemCount() (ticket #3720) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53998 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/generic/vlbox.cpp b/src/generic/vlbox.cpp index f30f2d9db3..f94031bca5 100644 --- a/src/generic/vlbox.cpp +++ b/src/generic/vlbox.cpp @@ -78,8 +78,8 @@ bool wxVListBox::Create(wxWindow *parent, const wxString& name) { #ifdef __WXMSW__ - if ((style & wxBORDER_MASK) == wxDEFAULT) - style |= wxBORDER_THEME; + if ( (style & wxBORDER_MASK) == wxDEFAULT ) + style |= wxBORDER_THEME; #endif style |= wxWANTS_CHARS | wxFULL_REPAINT_ON_RESIZE; @@ -110,6 +110,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