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

(cherry picked from commit 478e5101d9)
This commit is contained in:
wp_xyz 2022-04-06 00:14:48 +02:00 committed by Maxim Ganetsky
parent 1c8d13354d
commit bc8d0d2ae5

View File

@ -13120,8 +13120,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')