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
This commit is contained in:
wp_xxyyzz
2017-10-12 10:37:39 +00:00
parent a90fe39ab9
commit 38e00ec90d
2 changed files with 13 additions and 1 deletions

View File

@ -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;