diff options
author | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2012-08-02 17:52:51 +0100 |
---|---|---|
committer | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2012-08-02 17:52:51 +0100 |
commit | 5110b6c83555467d54744eabdd18049ea318f4b0 (patch) | |
tree | 3ef3cd9d6a9a48ffd368b5c70b4399191b2690b5 /src | |
parent | 1697e78142e8679c1bb4d19833cc1a64e1fd4c3b (diff) | |
download | fpGUI-5110b6c83555467d54744eabdd18049ea318f4b0.tar.xz |
report: Fixes a cause of corrupt memory
The images use in a PDF report get freed later. But if we used internally registered image,
the report engine frees those images, even though they might still be needed elsewhere
in the application. So for that reason we "clone" the internal image, which the report
engine can safely free.
Diffstat (limited to 'src')
-rw-r--r-- | src/reportengine/u_report.pas | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/reportengine/u_report.pas b/src/reportengine/u_report.pas index a1263927..94561f5f 100644 --- a/src/reportengine/u_report.pas +++ b/src/reportengine/u_report.pas @@ -2750,7 +2750,7 @@ end; procedure T_Report.ImagePage(Horiz, Verti: single; ImgFileName: string; ColNum, Scale: integer); var RefImage: integer; - Image: TfpgImage; + Image, TempImage: TfpgImage; begin Horiz := Dim2Pixels(Horiz); Verti := Dim2Pixels(Verti); @@ -2776,9 +2776,13 @@ begin RefImage := ImageNames.IndexOf(IntToStr(Scale) + ImgFileName); if RefImage = -1 then begin - Image := fpgImages.GetImage(ImgFileName); - Scale := 1; + { This returns a refence to an existing image } + TempImage := fpgImages.GetImage(ImgFileName); + Scale := 1; RefImage := ImageNames.Add(IntToStr(Scale) + ImgFileName); + { Clone the image because we don't want to free fpGUI registered images, + because they could be used by other widgets or areas of the application. } + Image := TempImage.ImageFromSource; Images.Add(Image); end; PaintImage(Horiz, Verti, ColNum, RefImage, zPage); |