LCL/StringGrid: Fix crash when Columns are exchanged and column indices are specified in reverse order.

This commit is contained in:
wp_xyz 2022-04-06 00:14:48 +02:00
parent dcc2d5d0d5
commit 478e5101d9

View File

@ -13226,8 +13226,15 @@ begin
if HasIndex(Index) then
if HasIndex(WithIndex) then begin
BeginUpdate;
Items[WithIndex].Index := Index;
Items[Index+1].Index := WithIndex;
if Index < WithIndex then
begin
Items[WithIndex].Index := Index;
Items[Index+1].Index := WithIndex;
end else
begin
Items[Index].Index := WithIndex;
Items[WithIndex+1].Index := Index;
end;
EndUpdate;
end else
raise Exception.Create('WithIndex out of range')