From 0c9dd3b69bd0b3804d9b4c703364730770f5a723 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 1 Jun 2012 22:34:17 +0000 Subject: [PATCH] Clear old selection when wxListBox becomes empty. When UpdateOldSelections() is called from wxListBox::DoClear(), it must clear the old selections array even for single selection list boxes, but it didn't do this under non-MSW platforms. Specifically check for the case of an empty listbox now and just forget the old selections then. This fixes the problem of keeping stale old selections and is also more efficient as we avoid the unnecessary GetSelections() call. Really closes #14359. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71637 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/lboxcmn.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/common/lboxcmn.cpp b/src/common/lboxcmn.cpp index ce0cbbb16e..0e1d050193 100644 --- a/src/common/lboxcmn.cpp +++ b/src/common/lboxcmn.cpp @@ -167,6 +167,14 @@ void wxListBoxBase::DeselectAll(int itemToLeaveSelected) void wxListBoxBase::UpdateOldSelections() { + // When the control becomes empty, any previously remembered selections are + // invalid anyhow, so just forget them. + if ( IsEmpty() ) + { + m_oldSelections.clear(); + return; + } + // We need to remember the selection even in single-selection case on // Windows, so that we don't send an event when the user clicks on an // already selected item. -- 2.45.2