mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-15 19:09:35 +02:00
Printers, carbon, initialize paperlist (and printerlist) array and check if it was allocated before releasing, issue #26435
git-svn-id: trunk@45789 -
This commit is contained in:
parent
90b05dca85
commit
679b76adf4
@ -205,6 +205,7 @@ var
|
||||
I, C: CFIndex;
|
||||
NewPrinterName: String;
|
||||
begin
|
||||
FPrinterArray := nil;
|
||||
if OSError(PMServerCreatePrinterList(kPMServerLocal, FPrinterArray),
|
||||
Self, 'DoEnumPrinters', 'PMServerCreatePrinterList') then Exit;
|
||||
|
||||
@ -224,7 +225,8 @@ end;
|
||||
|
||||
procedure TCarbonPrinter.EndEnumPrinters;
|
||||
begin
|
||||
CFRelease(FPrinterArray);
|
||||
if FPrinterArray<>nil then
|
||||
CFRelease(FPrinterArray);
|
||||
end;
|
||||
|
||||
procedure TCarbonPrinter.BeginEnumPapers(Lst: TStrings);
|
||||
@ -236,6 +238,7 @@ var
|
||||
const
|
||||
SName = 'DoEnumPapers';
|
||||
begin
|
||||
FPaperArray := nil;
|
||||
if OSError(PMPrinterGetPaperList(GetCurrentPrinter, FPaperArray),
|
||||
Self, SName, 'PMPrinterGetPaperList') then Exit;
|
||||
FPaperArray := CFRetain(FPaperArray);
|
||||
@ -260,7 +263,8 @@ end;
|
||||
|
||||
procedure TCarbonPrinter.EndEnumPapers;
|
||||
begin
|
||||
CFRelease(FPaperArray);
|
||||
if FPaperArray<>nil then
|
||||
CFRelease(FPaperArray);
|
||||
end;
|
||||
|
||||
constructor TCarbonPrinter.Create;
|
||||
|
Loading…
Reference in New Issue
Block a user