IDE: fixed wrong free of unit component dependencies

git-svn-id: trunk@14849 -
This commit is contained in:
mattias 2008-04-16 14:19:35 +00:00
parent b70cfb3a82
commit b93f8d1495
3 changed files with 40 additions and 3 deletions

View File

@ -49,7 +49,8 @@ uses
ComponentReg, IDEProcs, ComponentEditors, KeyMapping, EditorOptions,
DesignerProcs;
Const OrdinalTypes = [tkInteger,tkChar,tkENumeration,tkbool];
const
OrdinalTypes = [tkInteger,tkChar,tkEnumeration,tkbool];
type
{
@ -287,7 +288,7 @@ each control that's dropped onto the form
{ TDefinePropertiesPersistent
Wrapper class, to call the protected method 'DefineProperties' }
Wrapper/Friend class, to call the protected method 'DefineProperties' }
TDefinePropertiesPersistent = class(TPersistent)
private

View File

@ -627,6 +627,7 @@ type
Flags: TCloseFlags): TModalResult;
function UnitComponentIsUsed(AnUnitInfo: TUnitInfo;
CheckHasDesigner: boolean): boolean;
procedure UpdateUnitComponentDependencies;
// methods for creating a project
function CreateProjectObject(ProjectDesc,
@ -6079,6 +6080,11 @@ begin
exit(true);
end;
procedure TMainIDE.UpdateUnitComponentDependencies;
begin
Project1.UpdateUnitComponentDependencies;
end;
function TMainIDE.GetAncestorUnit(AnUnitInfo: TUnitInfo): TUnitInfo;
begin
if (AnUnitInfo=nil) or (AnUnitInfo.Component=nil) then

View File

@ -84,12 +84,18 @@ type
ucdlRequires,
ucdlUsedBy
);
TUnitCompDependencyType = (
ucdtAncestor, // RequiresUnit is ancestor
ucdtProperty // a property references RequiresUnit's component or sub component
);
TUnitCompDependencyTypes = set of TUnitCompDependencyType;
{ TUnitComponentDependency }
TUnitComponentDependency = class
private
FRequiresUnit: TUnitInfo;
FTypes: TUnitCompDependencyTypes;
FUsedByUnit: TUnitInfo;
procedure SetRequiresUnit(const AValue: TUnitInfo);
procedure SetUsedByUnit(const AValue: TUnitInfo);
@ -109,6 +115,7 @@ type
ListType: TUnitCompDependencyList);
property RequiresUnit: TUnitInfo read FRequiresUnit write SetRequiresUnit;
property UsedByUnit: TUnitInfo read FUsedByUnit write SetUsedByUnit;
property Types: TUnitCompDependencyTypes read FTypes write FTypes;
end;
//---------------------------------------------------------------------------
@ -235,6 +242,7 @@ type
// component dependencies
procedure AddRequiresComponentDependency(RequiredUnit: TUnitInfo);
procedure RemoveRequiresComponentDependency(RequiredUnit: TUnitInfo);
function FindComponentDependency(RequiredUnit: TUnitInfo): TUnitComponentDependency;
function FindAncestorUnit: TUnitInfo;
public
{ Properties }
@ -699,6 +707,9 @@ type
function Requires(APackage: TLazPackage): boolean;
procedure GetAllRequiredPackages(var List: TFPList);
procedure AddPackageDependency(const PackageName: string); override;
// unit dependencies
procedure UpdateUnitComponentDependencies;
// paths
procedure AddSrcPath(const SrcPathAddition: string); override;
@ -1336,8 +1347,22 @@ begin
end;
procedure TUnitInfo.RemoveRequiresComponentDependency(RequiredUnit: TUnitInfo);
var
Dependency: TUnitComponentDependency;
begin
RequiredUnit.Free;
Dependency:=FindComponentDependency(RequiredUnit);
if Dependency<>nil then
Dependency.Free;
end;
function TUnitInfo.FindComponentDependency(RequiredUnit: TUnitInfo
): TUnitComponentDependency;
begin
Result:=FirstRequiredComponent;
while Result<>nil do begin
if Result.RequiresUnit=RequiredUnit then exit;
Result:=Result.NextRequiresDependency;
end;
end;
function TUnitInfo.FindAncestorUnit: TUnitInfo;
@ -3346,6 +3371,11 @@ begin
AddRequiredDependency(PkgDependency);
end;
procedure TProject.UpdateUnitComponentDependencies;
begin
end;
procedure TProject.AddSrcPath(const SrcPathAddition: string);
begin
CompilerOptions.SrcPath:=MergeSearchPaths(CompilerOptions.SrcPath,