avoid too much allocs on software start-up

- this funct will be used a lot in the widget constructors
This commit is contained in:
Basile Burg 2015-09-17 17:50:03 +02:00
parent e6659329c9
commit 87fa0333fa
1 changed files with 14 additions and 16 deletions

View File

@ -9,12 +9,11 @@ procedure AssignPng(ctrl: TControl; const resName: string);
implementation
procedure AssignPng(ctrl: TControl; const resName: string);
var
png: TPortableNetworkGraphic;
procedure AssignPng(ctrl: TControl; const resName: string);
begin
png := TPortableNetworkGraphic.Create;
try
try
png.LoadFromLazarusResource(resName);
if ctrl is TCustomBitBtn then
@ -23,13 +22,12 @@ begin
TCustomSpeedButton(ctrl).Glyph.Assign(png);
except
end;
finally
png.Free;
end;
end;
initialization
png := TPortableNetworkGraphic.Create;
{$I ../src/ce_icons.inc}
finalization
png.Free;
end.