mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-03 06:43:15 +02:00
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:
parent
18dbe2687b
commit
76789e3c74
@ -926,6 +926,8 @@ type
|
|||||||
|
|
||||||
{ TControl }
|
{ TControl }
|
||||||
|
|
||||||
|
ELayoutException = class(Exception);
|
||||||
|
|
||||||
TControlAutoSizePhase = (
|
TControlAutoSizePhase = (
|
||||||
caspNone,
|
caspNone,
|
||||||
caspChangingProperties,
|
caspChangingProperties,
|
||||||
|
@ -332,7 +332,7 @@ procedure TControl.AdjustSize;
|
|||||||
|
|
||||||
procedure RaiseLoop;
|
procedure RaiseLoop;
|
||||||
begin
|
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;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -665,10 +665,9 @@ begin
|
|||||||
|
|
||||||
// check for loop.
|
// check for loop.
|
||||||
if (not KeepBase) and (cfKillChangeBounds in GetTopParent.FControlFlags) then
|
if (not KeepBase) and (cfKillChangeBounds in GetTopParent.FControlFlags) then
|
||||||
raise Exception.Create('TControl.ChangeBounds loop detected '+DbgSName(Self)
|
raise ELayoutException.CreateFmt('TControl.ChangeBounds loop detected %s '+
|
||||||
+' Left='+dbgs(Left)+',Top='+dbgs(Top)+',Width='+dbgs(Width)+',Height='+dbgs(Height)
|
'Left=%d,Top=%d,Width=%d,Height=%d NewLeft=%d,NewTop=%d,NewWidth=%d,NewHeight=%d',
|
||||||
+' NewLeft='+dbgs(aLeft)+',NewTop='+dbgs(aTop)+',NewWidth='+dbgs(aWidth)+',NewHeight='+dbgs(aHeight)
|
[DbgSName(Self), Left,Top,Width,Height, aLeft,aTop,aWidth,aHeight]);
|
||||||
);
|
|
||||||
OldLeft := FLeft;
|
OldLeft := FLeft;
|
||||||
OldTop := FTop;
|
OldTop := FTop;
|
||||||
OldWidth := FWidth;
|
OldWidth := FWidth;
|
||||||
@ -4244,13 +4243,11 @@ procedure TControl.SetWidth(Value: Integer);
|
|||||||
begin
|
begin
|
||||||
// the user changed the width
|
// the user changed the width
|
||||||
if Value<0 then
|
if Value<0 then
|
||||||
raise EInvalidOperation.Create(
|
raise ELayoutException.CreateFmt('TWinControl.SetBounds (%s): Negative width %d not allowed.',
|
||||||
'TWinControl.SetBounds ('+DbgSName(Self)+'): Negative width '
|
[DbgSName(Self), Value]);
|
||||||
+dbgs(Value)+' not allowed.');
|
|
||||||
if Value>=10000 then
|
if Value>=10000 then
|
||||||
raise EInvalidOperation.Create(
|
raise ELayoutException.CreateFmt('TWinControl.SetBounds (%s): Width %d not allowed.',
|
||||||
'TWinControl.SetBounds ('+DbgSName(Self)+'): Width '
|
[DbgSName(Self), Value]);
|
||||||
+dbgs(Value)+' not allowed.');
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -4288,13 +4285,11 @@ procedure TControl.SetHeight(Value: Integer);
|
|||||||
begin
|
begin
|
||||||
// the user changed the height
|
// the user changed the height
|
||||||
if Value<0 then
|
if Value<0 then
|
||||||
raise EInvalidOperation.Create(
|
raise ELayoutException.CreateFmt('TWinControl.SetHeight (%s): Negative height %d not allowed.',
|
||||||
'TWinControl.SetHeight ('+DbgSName(Self)+'): Negative height '
|
[DbgSName(Self), Value]);
|
||||||
+dbgs(Value)+' not allowed.');
|
|
||||||
if Value>=10000 then
|
if Value>=10000 then
|
||||||
raise EInvalidOperation.Create(
|
raise ELayoutException.CreateFmt('TWinControl.SetBounds (%s): Height %d not allowed.',
|
||||||
'TWinControl.SetBounds ('+DbgSName(Self)+'): Height '
|
[DbgSName(Self), Value]);
|
||||||
+dbgs(Value)+' not allowed.');
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -5628,7 +5623,7 @@ procedure TControl.InvalidatePreferredSize;
|
|||||||
|
|
||||||
procedure RaiseLoop;
|
procedure RaiseLoop;
|
||||||
begin
|
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;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -5725,10 +5720,9 @@ begin
|
|||||||
{$IFDEF DebugDisableAutoSizing}
|
{$IFDEF DebugDisableAutoSizing}
|
||||||
CheckReason;
|
CheckReason;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
if FAutoSizingLockCount<=0 then
|
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);
|
dec(FAutoSizingLockCount);
|
||||||
//DebugLn([Space(FAutoSizingLockCount*2),'TControl.EnableAutoSizing ',DbgSName(Self),' ',FAutoSizingLockCount]);
|
//DebugLn([Space(FAutoSizingLockCount*2),'TControl.EnableAutoSizing ',DbgSName(Self),' ',FAutoSizingLockCount]);
|
||||||
if (FAutoSizingLockCount=0) then
|
if (FAutoSizingLockCount=0) then
|
||||||
|
@ -123,8 +123,6 @@ begin
|
|||||||
SetScrollPos(Handle, SB_CTL, FMax - FPosition, True);
|
SetScrollPos(Handle, SB_CTL, FMax - FPosition, True);
|
||||||
Change;
|
Change;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
if HandleAllocated then
|
if HandleAllocated then
|
||||||
TWSScrollBarClass(WidgetSetClass).SetParams(Self);
|
TWSScrollBarClass(WidgetSetClass).SetParams(Self);
|
||||||
end;
|
end;
|
||||||
|
@ -4332,7 +4332,7 @@ begin
|
|||||||
SizeType := 6; // force realign
|
SizeType := 6; // force realign
|
||||||
if (FWidth < Low(Word)) or (FWidth > High(Word))
|
if (FWidth < Low(Word)) or (FWidth > High(Word))
|
||||||
or (FHeight < Low(Word)) or (FHeight > High(Word)) then
|
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=%d, Height=%d.', [Name, FWidth, FHeight]);
|
||||||
Width := FWidth;
|
Width := FWidth;
|
||||||
Height := FHeight;
|
Height := FHeight;
|
||||||
@ -4352,7 +4352,7 @@ begin
|
|||||||
MoveType:= 1;
|
MoveType:= 1;
|
||||||
if (FLeft < Low(Smallint)) or (FLeft > High(Smallint))
|
if (FLeft < Low(Smallint)) or (FLeft > High(Smallint))
|
||||||
or (FTop < Low(Smallint)) or (FTop > High(Smallint)) then
|
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]);
|
+' Left=%d, Top=%d.', [Name, FLeft, FTop]);
|
||||||
XPos := FLeft;
|
XPos := FLeft;
|
||||||
YPos := FTop;
|
YPos := FTop;
|
||||||
@ -6922,7 +6922,7 @@ var
|
|||||||
|
|
||||||
procedure RaiseLoop;
|
procedure RaiseLoop;
|
||||||
begin
|
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;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -6999,7 +6999,7 @@ var
|
|||||||
or (OldClientSize.cy<>NewClientSize.cy)
|
or (OldClientSize.cy<>NewClientSize.cy)
|
||||||
then
|
then
|
||||||
s:=s+' OldClientSize='+dbgs(OldClientSize)+' NewClientSize='+dbgs(NewClientSize);
|
s:=s+' OldClientSize='+dbgs(OldClientSize)+' NewClientSize='+dbgs(NewClientSize);
|
||||||
raise Exception.Create(s);
|
raise ELayoutException.Create(s);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -7124,7 +7124,7 @@ var
|
|||||||
|
|
||||||
procedure RaiseLoop;
|
procedure RaiseLoop;
|
||||||
begin
|
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;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -7947,7 +7947,8 @@ end;
|
|||||||
procedure TWinControl.EndUpdateBounds;
|
procedure TWinControl.EndUpdateBounds;
|
||||||
begin
|
begin
|
||||||
if FBoundsLockCount <= 0 then
|
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);
|
dec(FBoundsLockCount);
|
||||||
if FBoundsLockCount = 0 then
|
if FBoundsLockCount = 0 then
|
||||||
SetBounds(Left, Top, Width, Height);
|
SetBounds(Left, Top, Width, Height);
|
||||||
@ -8110,9 +8111,11 @@ procedure TWinControl.SetBounds(ALeft, ATop, AWidth, AHeight: integer);
|
|||||||
if FRealizeBoundsLockCount > 0 then Exit;
|
if FRealizeBoundsLockCount > 0 then Exit;
|
||||||
// the user changed the bounds
|
// the user changed the bounds
|
||||||
if AWidth < 0 then
|
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
|
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;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
|
Loading…
Reference in New Issue
Block a user