From 5885eea5ea72434311f2c706f57cff92a09ade91 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 17 Oct 2023 02:05:12 +0200 Subject: [PATCH] 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. --- src/generic/listctrl.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index 24951b4f09..b67277023c 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -3730,6 +3730,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;