TAChart: fix wmf drawer crashing due to missing canvas in TADrawerWMF

git-svn-id: trunk@44559 -
This commit is contained in:
wp 2014-03-30 19:51:14 +00:00
parent 7a5bfb6e30
commit 1e97dab2e1
2 changed files with 11 additions and 3 deletions

View File

@ -48,7 +48,7 @@ type
procedure Ellipse(AX1, AY1, AX2, AY2: Integer);
procedure FillRect(AX1, AY1, AX2, AY2: Integer);
function GetBrushColor: TChartColor;
function GetCanvas: TCanvas;
function GetCanvas: TCanvas; virtual;
procedure Line(AX1, AY1, AX2, AY2: Integer);
procedure Line(const AP1, AP2: TPoint);
procedure LineTo(AX, AY: Integer); override;

View File

@ -86,13 +86,13 @@ type
strict private
FFileName: String;
FMetafile: TMetafile;
FMetafileCanvas: TMetafileCanvas;
public
constructor Create(const AFileName: String); reintroduce;
destructor Destroy; override;
public
procedure DrawingBegin(const ABoundingBox: TRect); override;
procedure DrawingEnd; override;
function GetCanvas: TCanvas; override;
end;
implementation
@ -119,7 +119,8 @@ end;
procedure TWindowsMetafileDrawer.DrawingBegin(const ABoundingBox: TRect);
begin
inherited DrawingBegin(ABoundingBox);
FCanvas := TMetafileCanvas.Create(FMetafile, 0);
if FCanvas = nil then
FCanvas := TMetafileCanvas.Create(FMetafile, 0);
end;
procedure TWindowsMetafileDrawer.DrawingEnd;
@ -128,6 +129,13 @@ begin
FMetafile.SaveToFile(FFileName);
end;
function TWindowsMetafileDrawer.GetCanvas: TCanvas;
begin
if FCanvas = nil then
FCanvas := TMetafileCanvas.Create(FMetafile, 0);
Result := FCanvas;
end;
{ TMetafile }
procedure TMetafile.DeleteImage;