diff options
author | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2011-08-29 10:52:56 +0200 |
---|---|---|
committer | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2011-08-29 10:52:56 +0200 |
commit | 56174805a360732b822da8ab6e5f8c35a72be1f5 (patch) | |
tree | 150d73c9f96b35bc50d268c93026414d6c5c5625 /docview/components | |
parent | 7984792d4f6964900464ff2fadf4f7c7810e3fc6 (diff) | |
download | fpGUI-56174805a360732b822da8ab6e5f8c35a72be1f5.tar.xz |
richview: fixed memory leak with font resources.
Diffstat (limited to 'docview/components')
-rw-r--r-- | docview/components/richtext/CanvasFontManager.pas | 8 |
1 files changed, 7 insertions, 1 deletions
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; |