Fix refreshing wxGenericListCtrl with multiple selection

Changing the selection could behave wrongly and result in an assert
failure as the selection anchor could have become invalid, due to the
change of the number of items in the control.

Fix this by invalidating it when this happens.

(cherry picked from commit 5885eea5ea72434311f2c706f57cff92a09ade91)
This commit is contained in:
Vadim Zeitlin 2023-10-17 02:05:12 +02:00
parent cf66599eba
commit 0b0437af20
2 changed files with 8 additions and 0 deletions

View File

@ -235,6 +235,10 @@ Changes in behaviour which may result in build errors
3.2.4: (released 2024-??-??)
----------------------------
All (GUI):
- Fix refreshing multiple selection items in generic wxListCtrl.
wxMSW:
- Fix MSVS warning about redundant "const" in wx/itemid.h (#23590).

View File

@ -3782,6 +3782,10 @@ void wxListMainWindow::SetItemCount(long count)
if ( HasCurrent() && m_current >= (size_t)count )
ChangeCurrent(count - 1);
// And do the same thing for the multiple selection anchor.
if ( m_anchor != (size_t)-1 && m_anchor >= (size_t)count )
m_anchor = count - 1;
m_selStore.SetItemCount(count);
m_countVirt = count;