LCL: fix a bug in ListView introduced @0e0ef8c where the checked state was not restored correctly after sorting.

This commit is contained in:
rich2014 2025-03-04 22:01:35 +08:00
parent d73ca45293
commit 25e632015e

View File

@ -1144,19 +1144,18 @@ begin
TWSCustomListViewClass(WidgetSetClass).ItemSetState(Self, TWSCustomListViewClass(WidgetSetClass).ItemSetState(Self,
AItemIndex, Items[AItemIndex], lisSelected, True); AItemIndex, Items[AItemIndex], lisSelected, True);
end; end;
end;
if FSavedChecked <> nil then if FSavedChecked <> nil then
begin
for i := 0 to FSavedChecked.Count - 1 do
begin begin
for i := 0 to FSavedChecked.Count - 1 do FSavedCheckItem := TListItem( FSavedChecked[i] );
begin // todo: this is inefficient, because FSavedCheckItem.Index must be called again
FSavedCheckItem := TListItem( FSavedChecked[i] ); TWSCustomListViewClass(WidgetSetClass).ItemSetChecked(Self,
// todo: this is inefficient, because FSavedCheckItem.Index must be called again FSavedCheckItem.Index, FSavedCheckItem, True);
TWSCustomListViewClass(WidgetSetClass).ItemSetChecked(Self,
FSavedCheckItem.Index, FSavedCheckItem, True);
end;
FSavedChecked.Free;
end; end;
FSavedChecked.Free;
end; end;
finally finally
FreeThenNil(FSavedSelection); FreeThenNil(FSavedSelection);