LCL: Raise a specialized ELayoutException for LCL layout related errors. Issue #34362, patch from accorp.

git-svn-id: trunk@59274 -
This commit is contained in:
juha 2018-10-09 14:00:34 +00:00
parent 18dbe2687b
commit 76789e3c74
4 changed files with 28 additions and 31 deletions

View File

@ -926,6 +926,8 @@ type
{ TControl }
ELayoutException = class(Exception);
TControlAutoSizePhase = (
caspNone,
caspChangingProperties,

View File

@ -332,7 +332,7 @@ procedure TControl.AdjustSize;
procedure RaiseLoop;
begin
raise Exception.Create('TControl.AdjustSize loop detected '+DbgSName(Self)+' Bounds='+dbgs(BoundsRect));
raise ELayoutException.Create('TControl.AdjustSize loop detected '+DbgSName(Self)+' Bounds='+dbgs(BoundsRect));
end;
begin
@ -665,10 +665,9 @@ begin
// check for loop.
if (not KeepBase) and (cfKillChangeBounds in GetTopParent.FControlFlags) then
raise Exception.Create('TControl.ChangeBounds loop detected '+DbgSName(Self)
+' Left='+dbgs(Left)+',Top='+dbgs(Top)+',Width='+dbgs(Width)+',Height='+dbgs(Height)
+' NewLeft='+dbgs(aLeft)+',NewTop='+dbgs(aTop)+',NewWidth='+dbgs(aWidth)+',NewHeight='+dbgs(aHeight)
);
raise ELayoutException.CreateFmt('TControl.ChangeBounds loop detected %s '+
'Left=%d,Top=%d,Width=%d,Height=%d NewLeft=%d,NewTop=%d,NewWidth=%d,NewHeight=%d',
[DbgSName(Self), Left,Top,Width,Height, aLeft,aTop,aWidth,aHeight]);
OldLeft := FLeft;
OldTop := FTop;
OldWidth := FWidth;
@ -4244,13 +4243,11 @@ procedure TControl.SetWidth(Value: Integer);
begin
// the user changed the width
if Value<0 then
raise EInvalidOperation.Create(
'TWinControl.SetBounds ('+DbgSName(Self)+'): Negative width '
+dbgs(Value)+' not allowed.');
raise ELayoutException.CreateFmt('TWinControl.SetBounds (%s): Negative width %d not allowed.',
[DbgSName(Self), Value]);
if Value>=10000 then
raise EInvalidOperation.Create(
'TWinControl.SetBounds ('+DbgSName(Self)+'): Width '
+dbgs(Value)+' not allowed.');
raise ELayoutException.CreateFmt('TWinControl.SetBounds (%s): Width %d not allowed.',
[DbgSName(Self), Value]);
end;
begin
@ -4288,13 +4285,11 @@ procedure TControl.SetHeight(Value: Integer);
begin
// the user changed the height
if Value<0 then
raise EInvalidOperation.Create(
'TWinControl.SetHeight ('+DbgSName(Self)+'): Negative height '
+dbgs(Value)+' not allowed.');
raise ELayoutException.CreateFmt('TWinControl.SetHeight (%s): Negative height %d not allowed.',
[DbgSName(Self), Value]);
if Value>=10000 then
raise EInvalidOperation.Create(
'TWinControl.SetBounds ('+DbgSName(Self)+'): Height '
+dbgs(Value)+' not allowed.');
raise ELayoutException.CreateFmt('TWinControl.SetBounds (%s): Height %d not allowed.',
[DbgSName(Self), Value]);
end;
begin
@ -5628,7 +5623,7 @@ procedure TControl.InvalidatePreferredSize;
procedure RaiseLoop;
begin
raise Exception.Create('TControl.InvalidatePreferredSize loop detected '+DbgSName(Self)+' Bounds='+dbgs(BoundsRect));
raise ELayoutException.Create('TControl.InvalidatePreferredSize loop detected '+DbgSName(Self)+' Bounds='+dbgs(BoundsRect));
end;
var
@ -5725,10 +5720,9 @@ begin
{$IFDEF DebugDisableAutoSizing}
CheckReason;
{$ENDIF}
if FAutoSizingLockCount<=0 then
raise EInvalidOperation.Create('TControl.EnableAutoSizing '+DbgSName(Self)+': missing DisableAutoSizing');
raise ELayoutException.CreateFmt('TControl.EnableAutoSizing %s: missing DisableAutoSizing',
[DbgSName(Self)]);
dec(FAutoSizingLockCount);
//DebugLn([Space(FAutoSizingLockCount*2),'TControl.EnableAutoSizing ',DbgSName(Self),' ',FAutoSizingLockCount]);
if (FAutoSizingLockCount=0) then

View File

@ -123,8 +123,6 @@ begin
SetScrollPos(Handle, SB_CTL, FMax - FPosition, True);
Change;
end;
if HandleAllocated then
TWSScrollBarClass(WidgetSetClass).SetParams(Self);
end;

View File

@ -4332,7 +4332,7 @@ begin
SizeType := 6; // force realign
if (FWidth < Low(Word)) or (FWidth > High(Word))
or (FHeight < Low(Word)) or (FHeight > High(Word)) then
raise Exception.CreateFmt('Size range overflow in %s.SendMoveSizeMessages:'
raise ELayoutException.CreateFmt('Size range overflow in %s.SendMoveSizeMessages:'
+' Width=%d, Height=%d.', [Name, FWidth, FHeight]);
Width := FWidth;
Height := FHeight;
@ -4352,7 +4352,7 @@ begin
MoveType:= 1;
if (FLeft < Low(Smallint)) or (FLeft > High(Smallint))
or (FTop < Low(Smallint)) or (FTop > High(Smallint)) then
raise Exception.CreateFmt('Position range overflow in %s.SendMoveSizeMessages:'
raise ELayoutException.CreateFmt('Position range overflow in %s.SendMoveSizeMessages:'
+' Left=%d, Top=%d.', [Name, FLeft, FTop]);
XPos := FLeft;
YPos := FTop;
@ -6922,7 +6922,7 @@ var
procedure RaiseLoop;
begin
raise Exception.Create('TWinControl.WMMove loop detected: '+DbgSName(Self)+' BoundsRealized='+dbgs(FBoundsRealized)+' NewBoundsRealized='+dbgs(NewBoundsRealized));
raise ELayoutException.Create('TWinControl.WMMove loop detected: '+DbgSName(Self)+' BoundsRealized='+dbgs(FBoundsRealized)+' NewBoundsRealized='+dbgs(NewBoundsRealized));
end;
begin
@ -6999,7 +6999,7 @@ var
or (OldClientSize.cy<>NewClientSize.cy)
then
s:=s+' OldClientSize='+dbgs(OldClientSize)+' NewClientSize='+dbgs(NewClientSize);
raise Exception.Create(s);
raise ELayoutException.Create(s);
end;
begin
@ -7124,7 +7124,7 @@ var
procedure RaiseLoop;
begin
raise Exception.Create('TWinControl.WMWindowPosChanged loop detected: '+DbgSName(Self)+' BoundsRealized='+dbgs(FBoundsRealized)+' NewBoundsRealized='+dbgs(NewBoundsRealized));
raise ELayoutException.Create('TWinControl.WMWindowPosChanged loop detected: '+DbgSName(Self)+' BoundsRealized='+dbgs(FBoundsRealized)+' NewBoundsRealized='+dbgs(NewBoundsRealized));
end;
begin
@ -7947,7 +7947,8 @@ end;
procedure TWinControl.EndUpdateBounds;
begin
if FBoundsLockCount <= 0 then
raise EInvalidOperation.CreateFmt('TWinControl.EndUpdateBounds %s too many calls.', [DbgSName(Self)]);
raise ELayoutException.CreateFmt('TWinControl.EndUpdateBounds %s too many calls.',
[DbgSName(Self)]);
dec(FBoundsLockCount);
if FBoundsLockCount = 0 then
SetBounds(Left, Top, Width, Height);
@ -8110,9 +8111,11 @@ procedure TWinControl.SetBounds(ALeft, ATop, AWidth, AHeight: integer);
if FRealizeBoundsLockCount > 0 then Exit;
// the user changed the bounds
if AWidth < 0 then
raise EInvalidOperation.CreateFmt('TWinControl.SetBounds (%s): Negative width %d not allowed.', [DbgSName(Self), AWidth]);
raise ELayoutException.CreateFmt('TWinControl.SetBounds (%s): Negative width %d not allowed.',
[DbgSName(Self), AWidth]);
if AHeight < 0 then
raise EInvalidOperation.CreateFmt('TWinControl.SetBounds (%s): Negative height %d not allowed.', [DbgSName(Self), AHeight]);
raise ELayoutException.CreateFmt('TWinControl.SetBounds (%s): Negative height %d not allowed.',
[DbgSName(Self), AHeight]);
end;
var