mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-22 08:59:32 +02:00
IDE: when component is renamed, mark referring designers modified
git-svn-id: trunk@14881 -
This commit is contained in:
parent
3f1466b361
commit
dc8dfda3bc
26
ide/main.pp
26
ide/main.pp
@ -702,6 +702,7 @@ type
|
||||
function CreateNewUniqueFilename(const Prefix, Ext: string;
|
||||
NewOwner: TObject; Flags: TSearchIDEFileFlags; TryWithoutNumber: boolean
|
||||
): string; override;
|
||||
procedure MarkUnitsModifiedUsingSubComponent(SubComponent: TComponent);
|
||||
|
||||
// project(s)
|
||||
function DoNewProject(ProjectDesc: TProjectDescriptor): TModalResult; override;
|
||||
@ -7566,6 +7567,30 @@ begin
|
||||
until FileIsUnique(Result);
|
||||
end;
|
||||
|
||||
procedure TMainIDE.MarkUnitsModifiedUsingSubComponent(SubComponent: TComponent
|
||||
);
|
||||
var
|
||||
UnitList: TFPList;
|
||||
i: Integer;
|
||||
AnUnitInfo: TUnitInfo;
|
||||
ADesigner: TDesigner;
|
||||
begin
|
||||
UnitList:=TFPList.Create;
|
||||
Project1.FindUnitsUsingSubComponent(SubComponent,UnitList,true);
|
||||
for i:=0 to UnitList.Count-1 do begin
|
||||
AnUnitInfo:=TUnitInfo(UnitList[i]);
|
||||
if (AnUnitInfo.Component<>nil) then begin
|
||||
ADesigner:=TDesigner(FindRootDesigner(AnUnitInfo.Component));
|
||||
{$IFDEF VerboseIDEMultiForm}
|
||||
DebugLn(['TMainIDE.MarkUnitsModifiedUsingSubComponent ',AnUnitInfo.Filename,' ',dbgsName(ADesigner)]);
|
||||
{$ENDIF}
|
||||
if ADesigner is TDesigner then
|
||||
ADesigner.Modified;
|
||||
end;
|
||||
end;
|
||||
UnitList.Free;
|
||||
end;
|
||||
|
||||
function TMainIDE.LoadIDECodeBuffer(var ACodeBuffer: TCodeBuffer;
|
||||
const AFilename: string; Flags: TLoadBufferFlags): TModalResult;
|
||||
begin
|
||||
@ -13597,6 +13622,7 @@ begin
|
||||
if (AComponent.Owner=nil) then
|
||||
FormEditor1.UpdateDesignerFormName(AComponent);
|
||||
ObjectInspector1.FillPersistentComboBox;
|
||||
MarkUnitsModifiedUsingSubComponent(AComponent);
|
||||
end;
|
||||
|
||||
{-------------------------------------------------------------------------------
|
||||
|
@ -748,6 +748,8 @@ type
|
||||
procedure InvalidateUnitComponentDesignerDependencies;
|
||||
procedure ClearUnitComponentDependencies(
|
||||
ClearTypes: TUnitCompDependencyTypes);
|
||||
procedure FindUnitsUsingSubComponent(SubComponent: TComponent;
|
||||
List: TFPList; IgnoreOwner: boolean);
|
||||
|
||||
// paths
|
||||
procedure AddSrcPath(const SrcPathAddition: string); override;
|
||||
@ -3632,6 +3634,72 @@ begin
|
||||
Units[i].ClearUnitComponentDependencies(ClearTypes);
|
||||
end;
|
||||
|
||||
procedure TProject.FindUnitsUsingSubComponent(SubComponent: TComponent;
|
||||
List: TFPList; IgnoreOwner: boolean);
|
||||
|
||||
procedure Search(AnUnitInfo: TUnitInfo; AComponent: TComponent);
|
||||
// search the published properties of AComponent for references to other units
|
||||
var
|
||||
TypeInfo: PTypeInfo;
|
||||
TypeData: PTypeData;
|
||||
PropInfo: PPropInfo;
|
||||
CurCount: Word;
|
||||
ReferenceComponent: TComponent;
|
||||
begin
|
||||
// read all properties and remove doubles
|
||||
TypeInfo:=PTypeInfo(AComponent.ClassInfo);
|
||||
repeat
|
||||
// read all property infos of current class
|
||||
TypeData:=GetTypeData(TypeInfo);
|
||||
// skip unitname
|
||||
PropInfo:=PPropInfo(PByte(@TypeData^.UnitName)+Length(TypeData^.UnitName)+1);
|
||||
// read property count
|
||||
CurCount:=PWord(PropInfo)^;
|
||||
inc(PtrUInt(PropInfo),SizeOf(Word));
|
||||
|
||||
// read properties
|
||||
while CurCount>0 do begin
|
||||
// point PropInfo to next propinfo record.
|
||||
// Located at Name[Length(Name)+1] !
|
||||
if (PropInfo^.PropType=ClassTypeInfo(TComponent)) then begin
|
||||
// property of kind TComponent
|
||||
ReferenceComponent:=TComponent(GetObjectProp(AComponent,PropInfo));
|
||||
//debugln('TProject.FindUnitsUsingSubComponent Property ',dbgsName(AComponent),' Name=',PropInfo^.Name,' Type=',PropInfo^.PropType^.Name,' Value=',dbgsName(ReferenceComponent),' TypeInfo=',TypeInfo^.Name);
|
||||
if ReferenceComponent=SubComponent then begin
|
||||
if List.IndexOf(AnUnitInfo)<0 then
|
||||
List.Add(AnUnitInfo);
|
||||
end;
|
||||
end;
|
||||
PropInfo:=PPropInfo(pointer(@PropInfo^.Name)+PByte(@PropInfo^.Name)^+1);
|
||||
dec(CurCount);
|
||||
end;
|
||||
TypeInfo:=TypeData^.ParentInfo;
|
||||
until TypeInfo=nil;
|
||||
end;
|
||||
|
||||
var
|
||||
AnUnitInfo: TUnitInfo;
|
||||
i: Integer;
|
||||
OwnerComponent: TComponent;
|
||||
begin
|
||||
if SubComponent=nil then exit;
|
||||
if IgnoreOwner then begin
|
||||
OwnerComponent:=SubComponent;
|
||||
while OwnerComponent<>nil do
|
||||
OwnerComponent:=OwnerComponent.Owner;
|
||||
end else
|
||||
OwnerComponent:=nil;
|
||||
AnUnitInfo:=FirstUnitWithComponent;
|
||||
while AnUnitInfo<>nil do begin
|
||||
if AnUnitInfo.Component<>OwnerComponent then begin
|
||||
Search(AnUnitInfo,AnUnitInfo.Component);
|
||||
for i:=AnUnitInfo.Component.ComponentCount-1 downto 0 do
|
||||
Search(AnUnitInfo,AnUnitInfo.Component.Components[i]);
|
||||
end;
|
||||
AnUnitInfo:=AnUnitInfo.NextUnitWithComponent;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TProject.AddSrcPath(const SrcPathAddition: string);
|
||||
begin
|
||||
CompilerOptions.SrcPath:=MergeSearchPaths(CompilerOptions.SrcPath,
|
||||
|
Loading…
Reference in New Issue
Block a user