Skip to content

Commit 0b0437a

Browse files
committed
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 5885eea)
1 parent cf66599 commit 0b0437a

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

docs/changes.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,10 @@ Changes in behaviour which may result in build errors
235235
3.2.4: (released 2024-??-??)
236236
----------------------------
237237

238+
All (GUI):
239+
240+
- Fix refreshing multiple selection items in generic wxListCtrl.
241+
238242
wxMSW:
239243

240244
- Fix MSVS warning about redundant "const" in wx/itemid.h (#23590).

src/generic/listctrl.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3782,6 +3782,10 @@ void wxListMainWindow::SetItemCount(long count)
37823782
if ( HasCurrent() && m_current >= (size_t)count )
37833783
ChangeCurrent(count - 1);
37843784

3785+
// And do the same thing for the multiple selection anchor.
3786+
if ( m_anchor != (size_t)-1 && m_anchor >= (size_t)count )
3787+
m_anchor = count - 1;
3788+
37853789
m_selStore.SetItemCount(count);
37863790
m_countVirt = count;
37873791

0 commit comments

Comments
 (0)