lcl: prevent setbounds infinite loop (bug #0014474)

git-svn-id: trunk@21521 -
This commit is contained in:
paul 2009-09-01 14:37:48 +00:00
parent 5c235ca5a6
commit b66b9e6cb4
2 changed files with 9 additions and 2 deletions

View File

@ -107,7 +107,12 @@ begin
NewHeight := Height; NewHeight := Height;
//debugln('TCustomLabel.DoAutoSize ',dbgsName(Self),' Anchored ',dbgs(Left),',',dbgs(Top),',w=',dbgs(NewWidth),',h=',dbgs(NewHeight)); //debugln('TCustomLabel.DoAutoSize ',dbgsName(Self),' Anchored ',dbgs(Left),',',dbgs(Top),',w=',dbgs(NewWidth),',h=',dbgs(NewHeight));
SetBoundsKeepBase(Left, Top, NewWidth, NewHeight); FInternalSetBounds := True;
try
SetBoundsKeepBase(Left, Top, NewWidth, NewHeight);
finally
FInternalSetBounds := False;
end;
end; end;
procedure TCustomLabel.SetAlignment(Value : TAlignment); procedure TCustomLabel.SetAlignment(Value : TAlignment);
@ -211,6 +216,7 @@ begin
ControlStyle := [csSetCaption, csClickEvents, csDoubleClicks, csReplicatable]; ControlStyle := [csSetCaption, csClickEvents, csDoubleClicks, csReplicatable];
SetInitialBounds(0, 0, GetControlClassDefaultSize.X, GetControlClassDefaultSize.Y); SetInitialBounds(0, 0, GetControlClassDefaultSize.X, GetControlClassDefaultSize.Y);
FShowAccelChar := True; FShowAccelChar := True;
FInternalSetBounds := False;
Color := clNone; Color := clNone;
AutoSize := True; AutoSize := True;
end; end;
@ -478,7 +484,7 @@ end;
procedure TCustomLabel.SetBounds(aLeft, aTop, aWidth, aHeight: integer); procedure TCustomLabel.SetBounds(aLeft, aTop, aWidth, aHeight: integer);
begin begin
if AutoSize and WordWrap then if not FInternalSetBounds and AutoSize and WordWrap then
InvalidatePreferredSize; InvalidatePreferredSize;
inherited SetBounds(aLeft, aTop, aWidth, aHeight); inherited SetBounds(aLeft, aTop, aWidth, aHeight);
end; end;

View File

@ -1363,6 +1363,7 @@ type
FShowAccelChar: Boolean; FShowAccelChar: Boolean;
FWordWrap: Boolean; FWordWrap: Boolean;
FLayout: TTextLayout; FLayout: TTextLayout;
FInternalSetBounds: Boolean;
procedure SetAlignment(Value: TAlignment); procedure SetAlignment(Value: TAlignment);
procedure SetOptimalFill(const AValue: Boolean); procedure SetOptimalFill(const AValue: Boolean);
protected protected