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,27 +9,25 @@ procedure AssignPng(ctrl: TControl; const resName: string);
implementation
procedure AssignPng(ctrl: TControl; const resName: string);
var
png : TPortableNetworkGraphic;
begin
png := TPortableNetworkGraphic.Create;
try
try
png.LoadFromLazarusResource(resName);
if ctrl is TCustomBitBtn then
TCustomBitBtn(ctrl).Glyph.Assign(png)
else if ctrl is TCustomSpeedButton then
TCustomSpeedButton(ctrl).Glyph.Assign(png);
except
end;
finally
png.Free;
end;
png: TPortableNetworkGraphic;
procedure AssignPng(ctrl: TControl; const resName: string);
begin
try
png.LoadFromLazarusResource(resName);
if ctrl is TCustomBitBtn then
TCustomBitBtn(ctrl).Glyph.Assign(png)
else if ctrl is TCustomSpeedButton then
TCustomSpeedButton(ctrl).Glyph.Assign(png);
except
end;
end;
initialization
png := TPortableNetworkGraphic.Create;
{$I ../src/ce_icons.inc}
finalization
png.Free;
end.