IDE: designer: fixed mem leak

git-svn-id: trunk@16062 -
This commit is contained in:
mattias 2008-08-14 18:54:29 +00:00
parent 6ae9cd0b5c
commit 7ea9854894
2 changed files with 11 additions and 16 deletions

View File

@ -2092,22 +2092,21 @@ procedure TDesigner.Notification(AComponent: TComponent; Operation: TOperation);
Begin
if Operation = opInsert then begin
{$IFDEF VerboseDesigner}
DebugLn('opInsert ',AComponent.Name,':',AComponent.ClassName,' ',DbgS(AComponent));
DebugLn('opInsert ',dbgsName(AComponent),' ',DbgS(AComponent));
{$ENDIF}
if dfDeleting in FFlags then begin
// a component has auto created a new component during deletion
// -> ignore the new component
IgnoreDeletingPersistent.Add(AComponent);
end else begin
if TheFormEditor<>nil then
if (TheFormEditor<>nil) then
TheFormEditor.CreateComponentInterface(AComponent,false);
end;
end
else
if Operation = opRemove then begin
{$IFDEF VerboseDesigner}
DebugLn('[TDesigner.Notification] opRemove ',
AComponent.Name,':',AComponent.ClassName);
DebugLn('[TDesigner.Notification] opRemove ',dbgsName(AComponent));
{$ENDIF}
DoDeletePersistent(AComponent,false);
end;

View File

@ -77,7 +77,6 @@ each control that's dropped onto the form
Function GetPPropInfoByIndex(Index : Integer) : PPropInfo;
Function GetPPropInfoByName(Name : ShortString) : PPropInfo;
public
constructor Create;
constructor Create(AComponent: TComponent);
destructor Destroy; override;
@ -436,11 +435,6 @@ end;
{ TComponentInterface }
constructor TComponentInterface.Create;
begin
inherited Create;
end;
constructor TComponentInterface.Create(AComponent: TComponent);
begin
inherited Create;
@ -936,6 +930,8 @@ Begin
{$IFDEF IDE_DEBUG}
DebugLn(['TCustomFormEditor.DeleteComponent ',DbgSName(AComponent),' IsJITComponent=',IsJITComponent(AComponent),' FreeComponent=',FreeComponent]);
{$ENDIF}
if PropertyEditorHook.LookupRoot=AComponent then
PropertyEditorHook.LookupRoot:=nil;
IsJIT:=IsJITComponent(AComponent);
if IsJIT or (csInline in AComponent.ComponentState) then begin
i:=AComponent.ComponentCount-1;
@ -946,8 +942,6 @@ Begin
i:=AComponent.ComponentCount-1;
end;
end;
if PropertyEditorHook.LookupRoot=AComponent then
PropertyEditorHook.LookupRoot:=nil;
if IsJITComponent(AComponent) then begin
// value is a top level component
if JITFormList.IsJITForm(AComponent) then begin
@ -1566,8 +1560,8 @@ begin
end;
// create component interface
Temp := TComponentInterface.Create(NewComponent);
Temp:=TComponentInterface(CreateComponentInterface(NewComponent,false));
// calc parent
AParent:=nil;
if ParentComponent is TControl then begin
@ -1596,7 +1590,7 @@ begin
NewJITIndex := JITList.AddNewJITComponent(NewUnitName,TypeClass);
if NewJITIndex >= 0 then
// create component interface
Temp := TComponentInterface.Create(JITList[NewJITIndex])
Temp := TComponentInterface(CreateComponentInterface(JITList[NewJITIndex],false))
else
exit;
end;
@ -1700,7 +1694,9 @@ begin
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TCustomFormEditor.CreateComponent F ');{$ENDIF}
// add to component list
FComponentInterfaces.Add(Temp);
DebugLn(['TCustomFormEditor.CreateComponent ',dbgsName(Temp.Component),' ',FindComponent(Temp.Component)<>nil]);
if FindComponent(Temp.Component)=nil then
FComponentInterfaces.Add(Temp);
if Temp.Component.Owner<>nil then
CreateChildComponentInterfaces(Temp.Component.Owner);