From 56174805a360732b822da8ab6e5f8c35a72be1f5 Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Mon, 29 Aug 2011 10:52:56 +0200 Subject: richview: fixed memory leak with font resources. --- docview/components/richtext/CanvasFontManager.pas | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'docview/components') diff --git a/docview/components/richtext/CanvasFontManager.pas b/docview/components/richtext/CanvasFontManager.pas index 54e9755e..9e9114ec 100644 --- a/docview/components/richtext/CanvasFontManager.pas +++ b/docview/components/richtext/CanvasFontManager.pas @@ -35,6 +35,7 @@ type private FWidget: TfpgWidget; FCanvas: TfpgCanvas; + FFont: TfpgFont; function GetCurrentFont: TfpgFont; procedure SetDefaultFont(const AValue: TfpgFont); protected @@ -234,12 +235,14 @@ begin FWidget := AWidget; FDefaultFont := fpgGetFont(DefaultTopicFont); FCanvas.Font := FDefaultFont; + FFont := nil; end; destructor TCanvasFontManager.Destroy; begin FCanvas.Font := fpgApplication.DefaultFont; FDefaultFont.Free; + FFont.Free; inherited Destroy; end; @@ -269,7 +272,10 @@ begin Exit; end; - FCanvas.Font := fpgGetFont(AFontDesc); + if Assigned(FFont) then + FFont.Free; + FFont := fpgGetFont(AFontDesc); + FCanvas.Font := FFont; end; function TCanvasFontManager.CharWidth( const C: TfpgChar ): longint; -- cgit v1.2.3-70-g09d2