mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-02 04:48:17 +01:00
IDE: designer: fixed deleting pasted child controls from source, bug #11459
git-svn-id: trunk@15906 -
This commit is contained in:
parent
41d5425de5
commit
cdd9051f3a
@ -1924,7 +1924,7 @@ begin
|
|||||||
if DeletingPersistent.Count=0 then exit;
|
if DeletingPersistent.Count=0 then exit;
|
||||||
while DeletingPersistent.Count>0 do begin
|
while DeletingPersistent.Count>0 do begin
|
||||||
APersistent:=TPersistent(DeletingPersistent[DeletingPersistent.Count-1]);
|
APersistent:=TPersistent(DeletingPersistent[DeletingPersistent.Count-1]);
|
||||||
//writeln('TDesigner.DoDeleteSelectedComponents A ',AComponent.Name,':',AComponent.ClassName,' ',DbgS(AComponent));
|
//debugln(['TDesigner.DoDeleteSelectedComponents A ',dbgsName(APersistent),' ',(APersistent is TComponent) and (TheFormEditor.FindComponent(TComponent(APersistent))<>nil)]);
|
||||||
RemovePersistentAndChilds(APersistent);
|
RemovePersistentAndChilds(APersistent);
|
||||||
//writeln('TDesigner.DoDeleteSelectedComponents B ',DeletingPersistent.IndexOf(AComponent));
|
//writeln('TDesigner.DoDeleteSelectedComponents B ',DeletingPersistent.IndexOf(AComponent));
|
||||||
end;
|
end;
|
||||||
@ -1942,7 +1942,7 @@ var
|
|||||||
Hook: TPropertyEditorHook;
|
Hook: TPropertyEditorHook;
|
||||||
begin
|
begin
|
||||||
if APersistent=nil then exit;
|
if APersistent=nil then exit;
|
||||||
//writeln('TDesigner.DoDeleteComponent A ',AComponent.Name,':',AComponent.ClassName,' ',DbgS(AComponent));
|
//debugln(['TDesigner.DoDeletePersistent A ',dbgsName(APersistent),' FreeIt=',FreeIt]);
|
||||||
PopupMenuComponentEditor:=nil;
|
PopupMenuComponentEditor:=nil;
|
||||||
// unselect component
|
// unselect component
|
||||||
ControlSelection.Remove(APersistent);
|
ControlSelection.Remove(APersistent);
|
||||||
@ -1951,9 +1951,10 @@ begin
|
|||||||
// this component is currently in the process of deletion or the component
|
// this component is currently in the process of deletion or the component
|
||||||
// was not properly created
|
// was not properly created
|
||||||
// -> do not call handlers and simply get rid of the rubbish
|
// -> do not call handlers and simply get rid of the rubbish
|
||||||
//writeln('TDesigner.DoDeleteComponent UNKNOWN ',AComponent.Name,':',AComponent.ClassName,' ',DbgS(AComponent));
|
if FreeIt then begin
|
||||||
if FreeIt then
|
//debugln('TDesigner.DoDeletePersistent UNKNOWN in formeditor: ',dbgsName(APersistent));
|
||||||
APersistent.Free;
|
APersistent.Free;
|
||||||
|
end;
|
||||||
// unmark component
|
// unmark component
|
||||||
DeletingPersistent.Remove(APersistent);
|
DeletingPersistent.Remove(APersistent);
|
||||||
IgnoreDeletingPersistent.Remove(APersistent);
|
IgnoreDeletingPersistent.Remove(APersistent);
|
||||||
@ -2058,7 +2059,7 @@ var
|
|||||||
Begin
|
Begin
|
||||||
if APersistent=nil then exit;
|
if APersistent=nil then exit;
|
||||||
{$IFDEF VerboseDesigner}
|
{$IFDEF VerboseDesigner}
|
||||||
DebugLn('[TDesigner.RemovePersistentAndChilds] ',dbgsName(APersistent),' ',DbgS(APersistent));
|
DebugLn('[TDesigner.RemovePersistentAndChilds] START ',dbgsName(APersistent),' ',DbgS(APersistent));
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
if (APersistent=FLookupRoot) or (APersistent=Form)
|
if (APersistent=FLookupRoot) or (APersistent=Form)
|
||||||
or (IgnoreDeletingPersistent.IndexOf(APersistent)>=0)
|
or (IgnoreDeletingPersistent.IndexOf(APersistent)>=0)
|
||||||
@ -2069,9 +2070,9 @@ Begin
|
|||||||
i:=AWinControl.ControlCount-1;
|
i:=AWinControl.ControlCount-1;
|
||||||
while (i>=0) do begin
|
while (i>=0) do begin
|
||||||
ChildControl:=AWinControl.Controls[i];
|
ChildControl:=AWinControl.Controls[i];
|
||||||
if (ChildControl.Owner=FLookupRoot)
|
if (GetLookupRootForComponent(ChildControl)=FLookupRoot)
|
||||||
and (IgnoreDeletingPersistent.IndexOf(ChildControl)<0) then begin
|
and (IgnoreDeletingPersistent.IndexOf(ChildControl)<0) then begin
|
||||||
//Writeln('[TDesigner.RemoveComponentAndChilds] B ',AComponent.Name,':',AComponent.ClassName,' ',DbgS(AComponent),' Child=',ChildControl.Name,':',ChildControl.ClassName,' i=',i);
|
//Debugln(['[TDesigner.RemoveComponentAndChilds] B ',dbgsName(APersistent),' Child=',dbgsName(ChildControl),' i=',i,' ',TheFormEditor.FindComponent(ChildControl)<>nil]);
|
||||||
RemovePersistentAndChilds(ChildControl);
|
RemovePersistentAndChilds(ChildControl);
|
||||||
// the component list of the form has changed
|
// the component list of the form has changed
|
||||||
// -> restart the search
|
// -> restart the search
|
||||||
@ -2082,7 +2083,7 @@ Begin
|
|||||||
end;
|
end;
|
||||||
// remove component
|
// remove component
|
||||||
{$IFDEF VerboseDesigner}
|
{$IFDEF VerboseDesigner}
|
||||||
DebugLn('[TDesigner.RemovePersistentAndChilds] C ',dbgsName(APersistent));
|
DebugLn('[TDesigner.RemovePersistentAndChilds] DoDeletePersistent ',dbgsName(APersistent));
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
DoDeletePersistent(APersistent,true);
|
DoDeletePersistent(APersistent,true);
|
||||||
end;
|
end;
|
||||||
@ -2097,6 +2098,9 @@ Begin
|
|||||||
// a component has auto created a new component during deletion
|
// a component has auto created a new component during deletion
|
||||||
// -> ignore the new component
|
// -> ignore the new component
|
||||||
IgnoreDeletingPersistent.Add(AComponent);
|
IgnoreDeletingPersistent.Add(AComponent);
|
||||||
|
end else begin
|
||||||
|
if TheFormEditor<>nil then
|
||||||
|
TheFormEditor.CreateComponentInterface(AComponent,false);
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|||||||
@ -225,7 +225,7 @@ each control that's dropped onto the form
|
|||||||
function CreateUniqueComponentName(const AClassName: string;
|
function CreateUniqueComponentName(const AClassName: string;
|
||||||
OwnerComponent: TComponent): string;
|
OwnerComponent: TComponent): string;
|
||||||
function CreateComponentInterface(AComponent: TComponent;
|
function CreateComponentInterface(AComponent: TComponent;
|
||||||
WithChilds: Boolean): TIComponentInterface;
|
WithOwnedChilds: Boolean): TIComponentInterface;
|
||||||
procedure CreateChildComponentInterfaces(AComponent: TComponent);
|
procedure CreateChildComponentInterfaces(AComponent: TComponent);
|
||||||
function GetDefaultComponentParent(TypeClass: TComponentClass
|
function GetDefaultComponentParent(TypeClass: TComponentClass
|
||||||
): TIComponentInterface; override;
|
): TIComponentInterface; override;
|
||||||
@ -2396,14 +2396,14 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
Function TCustomFormEditor.CreateComponentInterface(
|
Function TCustomFormEditor.CreateComponentInterface(
|
||||||
AComponent: TComponent; WithChilds: Boolean): TIComponentInterface;
|
AComponent: TComponent; WithOwnedChilds: Boolean): TIComponentInterface;
|
||||||
Begin
|
Begin
|
||||||
Result:=FindComponent(AComponent);
|
Result:=FindComponent(AComponent);
|
||||||
if Result=nil then begin
|
if Result=nil then begin
|
||||||
Result := TComponentInterface.Create(AComponent);
|
Result := TComponentInterface.Create(AComponent);
|
||||||
FComponentInterfaces.Add(Result);
|
FComponentInterfaces.Add(Result);
|
||||||
end;
|
end;
|
||||||
if WithChilds then
|
if WithOwnedChilds then
|
||||||
CreateChildComponentInterfaces(AComponent);
|
CreateChildComponentInterfaces(AComponent);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
@ -11429,7 +11429,7 @@ var
|
|||||||
CurDesigner: TDesigner;
|
CurDesigner: TDesigner;
|
||||||
begin
|
begin
|
||||||
if not (APersistent is TComponent) then exit;
|
if not (APersistent is TComponent) then exit;
|
||||||
|
//DebugLn(['TMainIDE.OnPropHookPersistentDeleting ',dbgsName(APersistent)]);
|
||||||
CurDesigner:=TDesigner(FindRootDesigner(TComponent(APersistent)));
|
CurDesigner:=TDesigner(FindRootDesigner(TComponent(APersistent)));
|
||||||
if CurDesigner=nil then exit;
|
if CurDesigner=nil then exit;
|
||||||
|
|
||||||
@ -11455,6 +11455,7 @@ begin
|
|||||||
|
|
||||||
// remove component definition from owner source
|
// remove component definition from owner source
|
||||||
OwnerClassName:=CurDesigner.LookupRoot.ClassName;
|
OwnerClassName:=CurDesigner.LookupRoot.ClassName;
|
||||||
|
//DebugLn(['TMainIDE.OnPropHookPersistentDeleting ',dbgsName(APersistent),' OwnerClassName=',OwnerClassName]);
|
||||||
CodeToolBoss.RemovePublishedVariable(ActiveUnitInfo.Source,OwnerClassName,
|
CodeToolBoss.RemovePublishedVariable(ActiveUnitInfo.Source,OwnerClassName,
|
||||||
TComponent(APersistent).Name,false);
|
TComponent(APersistent).Name,false);
|
||||||
end;
|
end;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user