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
This commit is contained in:
@@ -167,6 +167,14 @@ void wxListBoxBase::DeselectAll(int itemToLeaveSelected)
|
|||||||
|
|
||||||
void wxListBoxBase::UpdateOldSelections()
|
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
|
// 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
|
// Windows, so that we don't send an event when the user clicks on an
|
||||||
// already selected item.
|
// already selected item.
|
||||||
|
Reference in New Issue
Block a user