LCL: Prevent an error when Monitor.PixelsPerInch=0 which may happen with GTK3 + Wayland. Issue #36220, patch from David.

git-svn-id: trunk@62212 -
This commit is contained in:
juha 2019-11-06 21:32:33 +00:00
parent 6fe903d537
commit 8e1067a191

View File

@ -70,17 +70,18 @@ end;
Gets called after the construction of the object Gets called after the construction of the object
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TCustomForm.AfterConstruction; procedure TCustomForm.AfterConstruction;
var
MonPPI: Integer;
begin begin
SetRestoredBounds(Left, Top, Width, Height, True); SetRestoredBounds(Left, Top, Width, Height, True);
DoCreate; DoCreate;
EndFormUpdate; // the BeginFormUpdate is in CreateNew EndFormUpdate; // the BeginFormUpdate is in CreateNew
inherited AfterConstruction; inherited AfterConstruction;
if Application.Scaled and Scaled and (Monitor.PixelsPerInch<>PixelsPerInch) then MonPPI := Monitor.PixelsPerInch;
AutoAdjustLayout(lapAutoAdjustForDPI, PixelsPerInch, Monitor.PixelsPerInch, if Application.Scaled and Scaled and (MonPPI > 0) and (MonPPI <> PixelsPerInch) then
Width, MulDiv(Width, Monitor.PixelsPerInch, PixelsPerInch)); AutoAdjustLayout(lapAutoAdjustForDPI, PixelsPerInch, MonPPI,
Width, MulDiv(Width, MonPPI, PixelsPerInch));
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -423,17 +424,19 @@ begin
end; end;
procedure TCustomForm.AutoScale; procedure TCustomForm.AutoScale;
var
MonPPI: Integer;
begin begin
if not Scaled then if not Scaled then
begin begin
Scaled := True; // will execute AutoScale Scaled := True; // will execute AutoScale
Exit; Exit;
end; end;
MonPPI := Monitor.PixelsPerInch;
if Application.Scaled and (PixelsPerInch<>Monitor.PixelsPerInch) then if Application.Scaled and (MonPPI > 0) and (MonPPI <> PixelsPerInch) then
AutoAdjustLayout(lapAutoAdjustForDPI, PixelsPerInch, Monitor.PixelsPerInch, AutoAdjustLayout(lapAutoAdjustForDPI, PixelsPerInch, MonPPI,
MulDiv(Width, Monitor.PixelsPerInch, PixelsPerInch), MulDiv(Width, MonPPI, PixelsPerInch),
MulDiv(Height, Monitor.PixelsPerInch, PixelsPerInch)); MulDiv(Height, MonPPI, PixelsPerInch));
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -2276,10 +2279,13 @@ end;
procedure TCustomForm.Show; procedure TCustomForm.Show;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TCustomForm.Show; procedure TCustomForm.Show;
var
MonPPI: Integer;
begin begin
if Application.Scaled and Scaled and (Monitor.PixelsPerInch<>PixelsPerInch) then MonPPI := Monitor.PixelsPerInch;
AutoAdjustLayout(lapAutoAdjustForDPI, PixelsPerInch, Monitor.PixelsPerInch, if Application.Scaled and Scaled and (MonPPI > 0) and (MonPPI <> PixelsPerInch) then
Width, MulDiv(Width, Monitor.PixelsPerInch, PixelsPerInch)); AutoAdjustLayout(lapAutoAdjustForDPI, PixelsPerInch, MonPPI,
Width, MulDiv(Width, MonPPI, PixelsPerInch));
Visible := True; Visible := True;
{ wxMaximized secondary forms are not being shown maximized } { wxMaximized secondary forms are not being shown maximized }