From 38e00ec90d4e6b85eaf8d7a34258071cddbef0e6 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Thu, 12 Oct 2017 10:37:39 +0000 Subject: [PATCH] spktoolbar: Fix "bitmap handle leak" (issue discussed in https://sourceforge.net/p/lazarus-ccr/bugs/35/) git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6037 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/spktoolbar/SpkGUITools/SpkGUITools.pas | 13 ++++++++++++- components/spktoolbar/demos/actions/project1.lpr | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/components/spktoolbar/SpkGUITools/SpkGUITools.pas b/components/spktoolbar/SpkGUITools/SpkGUITools.pas index 1ae9dd0a2..30d37d497 100644 --- a/components/spktoolbar/SpkGUITools/SpkGUITools.pas +++ b/components/spktoolbar/SpkGUITools/SpkGUITools.pas @@ -1918,6 +1918,17 @@ if UseOrgClipRgn then SelectClipRgn(ACanvas.Handle, ClipRgn); +{ wp: Next part fixes issue https://sourceforge.net/p/lazarus-ccr/bugs/35/ } +ImageBitmap := TBitmap.Create; +ImageList.GetBitmap(ImageIndex, ImageBitmap); +ACanvas.Draw(Point.x, Point.y, ImageBitmap); +ImageBitmap.Free; + +{ wp: The following lines were removed and replaced by the "ImageBitmap" lines + above in order to fix the "handle leak" of + https://sourceforge.net/p/lazarus-ccr/bugs/35/ + Not daring to touch the ImageList.Draw which would have worked as well. } +{ // avoid exclusive draw. draw with local canvas itself. //ImageList.Draw(ACanvas, Point.x, Point.y, ImageIndex); {$IfDef LCLWin32} @@ -1931,7 +1942,7 @@ ImageList.GetBitmap(ImageIndex, ImageBitmap); ACanvas.Draw(Point.x, Point.y, ImageBitmap); ImageBitmap.Free; {$EndIf} - +} RestoreClipRgn(ACanvas.Handle, UseOrgClipRgn, OrgRgn); DeleteObject(ClipRgn); end; diff --git a/components/spktoolbar/demos/actions/project1.lpr b/components/spktoolbar/demos/actions/project1.lpr index 1ebe3eb71..bc1c90651 100644 --- a/components/spktoolbar/demos/actions/project1.lpr +++ b/components/spktoolbar/demos/actions/project1.lpr @@ -13,6 +13,7 @@ uses {$R *.res} begin + Application.Scaled := True; {$IF lcl_fullversion >= 1080000} Application.Scaled := True; {$ENDIF}