Skip to content

Commit cb69e76

Browse files
committed
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 8d036af)
1 parent 20d4f2f commit cb69e76

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

docs/changes.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ wxGTK:
306306
- Fix wxPreferencesEditor size under Wayland (#23924).
307307
- Fix not showing text in wxBusyInfo (#23936).
308308
- Make wxRB_SINGLE really work (Stefan Hansson, #23652).
309+
- Fix (not) refreshing virtual wxListCtrl after deleting its last item.
309310

310311
wxMSW:
311312

src/generic/listctrl.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1992,13 +1992,16 @@ void wxListMainWindow::RefreshAfter( size_t lineFrom )
19921992
{
19931993
if ( InReportView() )
19941994
{
1995-
size_t visibleFrom, visibleTo;
1996-
GetVisibleLinesRange(&visibleFrom, &visibleTo);
1995+
// Note that we don't compare lineFrom with the last visible line
1996+
// because we refresh the entire rectangle below it anyhow, so it
1997+
// doesn't matter if it's bigger than it. And we must still refresh
1998+
// even if lineFrom is invalid because it may have been (just) deleted
1999+
// when we're called from DeleteItem().
2000+
size_t visibleFrom;
2001+
GetVisibleLinesRange(&visibleFrom, nullptr);
19972002

19982003
if ( lineFrom < visibleFrom )
19992004
lineFrom = visibleFrom;
2000-
else if ( lineFrom > visibleTo )
2001-
return;
20022005

20032006
wxRect rect;
20042007
rect.x = 0;

0 commit comments

Comments
 (0)