Fix not refreshing generic wxListCtrl after deleting last item

The check for the line being deleted being in the visible range
prevented us from refreshing anything at all if the line which was just
deleted was the last line of the control.

(cherry picked from commit 8d036af8160d303b67944d781d27ff58b058f839)
This commit is contained in:
Vadim Zeitlin 2023-10-06 18:17:15 +02:00
parent 20d4f2fb43
commit cb69e76897
2 changed files with 8 additions and 4 deletions

View File

@ -306,6 +306,7 @@ wxGTK:
- Fix wxPreferencesEditor size under Wayland (#23924). - Fix wxPreferencesEditor size under Wayland (#23924).
- Fix not showing text in wxBusyInfo (#23936). - Fix not showing text in wxBusyInfo (#23936).
- Make wxRB_SINGLE really work (Stefan Hansson, #23652). - Make wxRB_SINGLE really work (Stefan Hansson, #23652).
- Fix (not) refreshing virtual wxListCtrl after deleting its last item.
wxMSW: wxMSW:

View File

@ -1992,13 +1992,16 @@ void wxListMainWindow::RefreshAfter( size_t lineFrom )
{ {
if ( InReportView() ) if ( InReportView() )
{ {
size_t visibleFrom, visibleTo; // Note that we don't compare lineFrom with the last visible line
GetVisibleLinesRange(&visibleFrom, &visibleTo); // because we refresh the entire rectangle below it anyhow, so it
// doesn't matter if it's bigger than it. And we must still refresh
// even if lineFrom is invalid because it may have been (just) deleted
// when we're called from DeleteItem().
size_t visibleFrom;
GetVisibleLinesRange(&visibleFrom, nullptr);
if ( lineFrom < visibleFrom ) if ( lineFrom < visibleFrom )
lineFrom = visibleFrom; lineFrom = visibleFrom;
else if ( lineFrom > visibleTo )
return;
wxRect rect; wxRect rect;
rect.x = 0; rect.x = 0;