IDE: package editor: add new component: do not add dependency if already indirectly required

git-svn-id: trunk@35197 -
This commit is contained in:
mattias 2012-02-06 21:36:23 +00:00
parent f819ed7030
commit 7360413d68
2 changed files with 25 additions and 9 deletions

View File

@ -34,17 +34,14 @@
<OutDir Value="languages"/>
</i18n>
<Type Value="RunAndDesignTime"/>
<RequiredPkgs Count="3">
<RequiredPkgs Count="2">
<Item1>
<PackageName Value="LCL"/>
<PackageName Value="IDEIntf"/>
</Item1>
<Item2>
<PackageName Value="IDEIntf"/>
</Item2>
<Item3>
<PackageName Value="FCL"/>
<MinVersion Major="1" Valid="True"/>
</Item3>
</Item2>
</RequiredPkgs>
<UsageOptions>
<UnitPath Value="$(PkgOutDir)"/>

View File

@ -1463,6 +1463,26 @@ function TPackageEditorForm.ShowAddDialog(var DlgPage: TAddToPkgType
var
IgnoreUnitPaths, IgnoreIncPaths: TFilenameToStringTree;
function PkgDependsOn(PkgName: string): boolean;
var
List: TFPList;
i: Integer;
begin
if PkgName='' then exit;
List:=nil;
try
LazPackage.GetAllRequiredPackages(List,true);
if (List<>nil) then begin
for i:=0 to List.Count-1 do
if SysUtils.CompareText(TLazPackage(List[i]).Name,PkgName)=0 then
exit(true);
end;
finally
List.Free;
end;
Result:=false;
end;
procedure AddUnit(AddParams: TAddToPkgResult);
var
NewLFMFilename: String;
@ -1516,11 +1536,10 @@ var
PkgFileFlags,cpNormal);
// add dependency
if (AddParams.Dependency<>nil)
and (LazPackage.FindDependencyByName(AddParams.Dependency.PackageName)=nil)
then
and (not PkgDependsOn(AddParams.Dependency.PackageName)) then
PackageGraph.AddDependencyToPackage(LazPackage,AddParams.Dependency);
if (AddParams.IconFile<>'')
and (LazPackage.FindDependencyByName('LCL')=nil) then
and (not PkgDependsOn('LCL')) then
PackageGraph.AddDependencyToPackage(LazPackage,PackageGraph.LCLPackage);
PackageEditors.DeleteAmbiguousFiles(LazPackage,AddParams.UnitFilename);
// open file in editor