From d444ee76f9a841ec1750affb734e90dfec568779 Mon Sep 17 00:00:00 2001 From: zeljko Date: Mon, 27 Aug 2012 08:57:04 +0000 Subject: [PATCH] LCL: ColorBox - keep FSelected in sync all the time. fixes issue #22729 git-svn-id: trunk@38396 - --- lcl/colorbox.pas | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lcl/colorbox.pas b/lcl/colorbox.pas index 852c01786a..1c4946bd01 100644 --- a/lcl/colorbox.pas +++ b/lcl/colorbox.pas @@ -376,8 +376,15 @@ begin if HandleAllocated then begin if ItemIndex <> -1 then - Result := Colors[ItemIndex] - else + begin + Result := Colors[ItemIndex]; + // keep FSelected in sync + if FSelected <> Result then + begin + // DebugLn('WARNING TCustomColorBox: FSelected out of sync with Colors[0]'); + FSelected := Result; + end; + end else Result := FSelected; end else @@ -432,7 +439,7 @@ end; ------------------------------------------------------------------------------} procedure TCustomColorBox.SetSelected(Value: TColor); begin - if Selected = Value then + if FSelected = Value then Exit; FSelected := Value; @@ -620,7 +627,7 @@ begin if (cbCustomColor in Style) and (ItemIndex = 0) then // custom color has been selected PickCustomColor; if ItemIndex <> -1 then - FSelected := Colors[ItemIndex]; + Selected := Colors[ItemIndex]; inherited CloseUp; end;