mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 16:00:16 +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;
|
I, C: CFIndex;
|
||||||
NewPrinterName: String;
|
NewPrinterName: String;
|
||||||
begin
|
begin
|
||||||
|
FPrinterArray := nil;
|
||||||
if OSError(PMServerCreatePrinterList(kPMServerLocal, FPrinterArray),
|
if OSError(PMServerCreatePrinterList(kPMServerLocal, FPrinterArray),
|
||||||
Self, 'DoEnumPrinters', 'PMServerCreatePrinterList') then Exit;
|
Self, 'DoEnumPrinters', 'PMServerCreatePrinterList') then Exit;
|
||||||
|
|
||||||
@ -224,7 +225,8 @@ end;
|
|||||||
|
|
||||||
procedure TCarbonPrinter.EndEnumPrinters;
|
procedure TCarbonPrinter.EndEnumPrinters;
|
||||||
begin
|
begin
|
||||||
CFRelease(FPrinterArray);
|
if FPrinterArray<>nil then
|
||||||
|
CFRelease(FPrinterArray);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCarbonPrinter.BeginEnumPapers(Lst: TStrings);
|
procedure TCarbonPrinter.BeginEnumPapers(Lst: TStrings);
|
||||||
@ -236,6 +238,7 @@ var
|
|||||||
const
|
const
|
||||||
SName = 'DoEnumPapers';
|
SName = 'DoEnumPapers';
|
||||||
begin
|
begin
|
||||||
|
FPaperArray := nil;
|
||||||
if OSError(PMPrinterGetPaperList(GetCurrentPrinter, FPaperArray),
|
if OSError(PMPrinterGetPaperList(GetCurrentPrinter, FPaperArray),
|
||||||
Self, SName, 'PMPrinterGetPaperList') then Exit;
|
Self, SName, 'PMPrinterGetPaperList') then Exit;
|
||||||
FPaperArray := CFRetain(FPaperArray);
|
FPaperArray := CFRetain(FPaperArray);
|
||||||
@ -260,7 +263,8 @@ end;
|
|||||||
|
|
||||||
procedure TCarbonPrinter.EndEnumPapers;
|
procedure TCarbonPrinter.EndEnumPapers;
|
||||||
begin
|
begin
|
||||||
CFRelease(FPaperArray);
|
if FPaperArray<>nil then
|
||||||
|
CFRelease(FPaperArray);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TCarbonPrinter.Create;
|
constructor TCarbonPrinter.Create;
|
||||||
|
Loading…
Reference in New Issue
Block a user