LazReport: moved printer initial setup out of unit's initialization, patch from Zdravko Gabrovski with changes, fix issue #37065

git-svn-id: trunk@63221 -
This commit is contained in:
jesus 2020-05-25 16:57:23 +00:00
parent 254e43bb4f
commit f107619061

View File

@ -71,14 +71,16 @@ type
property PrinterIndex: Integer read FPrinterIndex write SetPrinterIndex;
end;
var
Prn: TfrPrinter;
function Prn : TfrPrinter;
const
MAX_TYP_KNOWN = 118;
implementation
var
GlobalPrn: TfrPrinter = nil;
type
TPaperInfo = record
Typ: Integer;
@ -363,6 +365,25 @@ const
//
{$ENDIF}
function Prn: TfrPrinter;
begin
if Assigned( GlobalPrn ) then
Exit( GlobalPrn );
GlobalPrn := TfrPrinter.Create;
try
GlobalPrn.Printer:=Printer;
except
on E: Exception do begin
debugln('lazreport: unit lr_prntr: ',E.Message);
end;
end;
Exit( GlobalPrn );
end;
{----------------------------------------------------------------------------}
constructor TfrPrinter.Create;
var
@ -1245,16 +1266,9 @@ end;
{----------------------------------------------------------------------------}
initialization
Prn := TfrPrinter.Create;
try
Prn.Printer:=Printer;
except
on E: Exception do begin
debugln('lazreport: unit lr_prntr: ',E.Message);
end;
end;
finalization
Prn.Free;
if Assigned( GlobalPrn ) then
GlobalPrn.Free;
end.