[Lazarus] Inserting many components on form

fluisgirardi at gmail.com fluisgirardi at gmail.com
Mon Jun 27 21:04:49 CEST 2011


I wrote a component editor that can insert some components on a form or data
module. But when I insert many components, the performance of lazarus is
 terrible. Inserting 510 components on my I5 540M with 8Gb of Ram takes 14
seconds. If I try insert 1020 components, this action takes 52 seconds.
If I try insert 4000 components, I don't know how many time this action
takes, because it freezes the Lazarus for a long time.

My component editor class has two methods:

procedure TInsertTagsOnFormComponentEditor.AddTagInEditor(Tag:TTag);
{$IFDEF FPC}
var
 Hook: TPropertyEditorHook;
{$ENDIF}
begin
{$IFDEF FPC}
 Hook:=nil;
 if not GetHook(Hook) then exit;
 Hook.PersistentAdded(Tag,false);
 Modified;
{$ELSE}
 Designer.Modified;
{$ENDIF}
end;

function
 TInsertTagsOnFormComponentEditor.CreateComponent(tagclass:TComponentClass):TComponent;
begin
 {$IFDEF FPC}
   Result := tagclass.Create(GetTheOwner);
 {$ELSE}
   Result := Designer.CreateComponent(tagclass,GetTheOwner,0,0,0,0);
 {$ENDIF}
end;


To use this editor, the component wizard call (to each component created):


obj:= componentClass(compeditor.CreateComponent(componentClass));
compeditor.AddTagInEditor(obj);

Somebody did something like this? Am I doing something wrong? What's the
Lazarus pieces that mus be improved to perform this action more fastest?


The best regards,

Fabio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20110627/e600ce25/attachment-0002.html>


More information about the Lazarus mailing list