mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-13 21:29:10 +02:00
IDE: fixed wrong free of unit component dependencies
git-svn-id: trunk@14849 -
This commit is contained in:
parent
b70cfb3a82
commit
b93f8d1495
@ -49,7 +49,8 @@ uses
|
|||||||
ComponentReg, IDEProcs, ComponentEditors, KeyMapping, EditorOptions,
|
ComponentReg, IDEProcs, ComponentEditors, KeyMapping, EditorOptions,
|
||||||
DesignerProcs;
|
DesignerProcs;
|
||||||
|
|
||||||
Const OrdinalTypes = [tkInteger,tkChar,tkENumeration,tkbool];
|
const
|
||||||
|
OrdinalTypes = [tkInteger,tkChar,tkEnumeration,tkbool];
|
||||||
|
|
||||||
type
|
type
|
||||||
{
|
{
|
||||||
@ -287,7 +288,7 @@ each control that's dropped onto the form
|
|||||||
|
|
||||||
|
|
||||||
{ TDefinePropertiesPersistent
|
{ TDefinePropertiesPersistent
|
||||||
Wrapper class, to call the protected method 'DefineProperties' }
|
Wrapper/Friend class, to call the protected method 'DefineProperties' }
|
||||||
|
|
||||||
TDefinePropertiesPersistent = class(TPersistent)
|
TDefinePropertiesPersistent = class(TPersistent)
|
||||||
private
|
private
|
||||||
|
@ -627,6 +627,7 @@ type
|
|||||||
Flags: TCloseFlags): TModalResult;
|
Flags: TCloseFlags): TModalResult;
|
||||||
function UnitComponentIsUsed(AnUnitInfo: TUnitInfo;
|
function UnitComponentIsUsed(AnUnitInfo: TUnitInfo;
|
||||||
CheckHasDesigner: boolean): boolean;
|
CheckHasDesigner: boolean): boolean;
|
||||||
|
procedure UpdateUnitComponentDependencies;
|
||||||
|
|
||||||
// methods for creating a project
|
// methods for creating a project
|
||||||
function CreateProjectObject(ProjectDesc,
|
function CreateProjectObject(ProjectDesc,
|
||||||
@ -6079,6 +6080,11 @@ begin
|
|||||||
exit(true);
|
exit(true);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMainIDE.UpdateUnitComponentDependencies;
|
||||||
|
begin
|
||||||
|
Project1.UpdateUnitComponentDependencies;
|
||||||
|
end;
|
||||||
|
|
||||||
function TMainIDE.GetAncestorUnit(AnUnitInfo: TUnitInfo): TUnitInfo;
|
function TMainIDE.GetAncestorUnit(AnUnitInfo: TUnitInfo): TUnitInfo;
|
||||||
begin
|
begin
|
||||||
if (AnUnitInfo=nil) or (AnUnitInfo.Component=nil) then
|
if (AnUnitInfo=nil) or (AnUnitInfo.Component=nil) then
|
||||||
|
@ -84,12 +84,18 @@ type
|
|||||||
ucdlRequires,
|
ucdlRequires,
|
||||||
ucdlUsedBy
|
ucdlUsedBy
|
||||||
);
|
);
|
||||||
|
TUnitCompDependencyType = (
|
||||||
|
ucdtAncestor, // RequiresUnit is ancestor
|
||||||
|
ucdtProperty // a property references RequiresUnit's component or sub component
|
||||||
|
);
|
||||||
|
TUnitCompDependencyTypes = set of TUnitCompDependencyType;
|
||||||
|
|
||||||
{ TUnitComponentDependency }
|
{ TUnitComponentDependency }
|
||||||
|
|
||||||
TUnitComponentDependency = class
|
TUnitComponentDependency = class
|
||||||
private
|
private
|
||||||
FRequiresUnit: TUnitInfo;
|
FRequiresUnit: TUnitInfo;
|
||||||
|
FTypes: TUnitCompDependencyTypes;
|
||||||
FUsedByUnit: TUnitInfo;
|
FUsedByUnit: TUnitInfo;
|
||||||
procedure SetRequiresUnit(const AValue: TUnitInfo);
|
procedure SetRequiresUnit(const AValue: TUnitInfo);
|
||||||
procedure SetUsedByUnit(const AValue: TUnitInfo);
|
procedure SetUsedByUnit(const AValue: TUnitInfo);
|
||||||
@ -109,6 +115,7 @@ type
|
|||||||
ListType: TUnitCompDependencyList);
|
ListType: TUnitCompDependencyList);
|
||||||
property RequiresUnit: TUnitInfo read FRequiresUnit write SetRequiresUnit;
|
property RequiresUnit: TUnitInfo read FRequiresUnit write SetRequiresUnit;
|
||||||
property UsedByUnit: TUnitInfo read FUsedByUnit write SetUsedByUnit;
|
property UsedByUnit: TUnitInfo read FUsedByUnit write SetUsedByUnit;
|
||||||
|
property Types: TUnitCompDependencyTypes read FTypes write FTypes;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
@ -235,6 +242,7 @@ type
|
|||||||
// component dependencies
|
// component dependencies
|
||||||
procedure AddRequiresComponentDependency(RequiredUnit: TUnitInfo);
|
procedure AddRequiresComponentDependency(RequiredUnit: TUnitInfo);
|
||||||
procedure RemoveRequiresComponentDependency(RequiredUnit: TUnitInfo);
|
procedure RemoveRequiresComponentDependency(RequiredUnit: TUnitInfo);
|
||||||
|
function FindComponentDependency(RequiredUnit: TUnitInfo): TUnitComponentDependency;
|
||||||
function FindAncestorUnit: TUnitInfo;
|
function FindAncestorUnit: TUnitInfo;
|
||||||
public
|
public
|
||||||
{ Properties }
|
{ Properties }
|
||||||
@ -699,6 +707,9 @@ type
|
|||||||
function Requires(APackage: TLazPackage): boolean;
|
function Requires(APackage: TLazPackage): boolean;
|
||||||
procedure GetAllRequiredPackages(var List: TFPList);
|
procedure GetAllRequiredPackages(var List: TFPList);
|
||||||
procedure AddPackageDependency(const PackageName: string); override;
|
procedure AddPackageDependency(const PackageName: string); override;
|
||||||
|
|
||||||
|
// unit dependencies
|
||||||
|
procedure UpdateUnitComponentDependencies;
|
||||||
|
|
||||||
// paths
|
// paths
|
||||||
procedure AddSrcPath(const SrcPathAddition: string); override;
|
procedure AddSrcPath(const SrcPathAddition: string); override;
|
||||||
@ -1336,8 +1347,22 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TUnitInfo.RemoveRequiresComponentDependency(RequiredUnit: TUnitInfo);
|
procedure TUnitInfo.RemoveRequiresComponentDependency(RequiredUnit: TUnitInfo);
|
||||||
|
var
|
||||||
|
Dependency: TUnitComponentDependency;
|
||||||
begin
|
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;
|
end;
|
||||||
|
|
||||||
function TUnitInfo.FindAncestorUnit: TUnitInfo;
|
function TUnitInfo.FindAncestorUnit: TUnitInfo;
|
||||||
@ -3346,6 +3371,11 @@ begin
|
|||||||
AddRequiredDependency(PkgDependency);
|
AddRequiredDependency(PkgDependency);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TProject.UpdateUnitComponentDependencies;
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TProject.AddSrcPath(const SrcPathAddition: string);
|
procedure TProject.AddSrcPath(const SrcPathAddition: string);
|
||||||
begin
|
begin
|
||||||
CompilerOptions.SrcPath:=MergeSearchPaths(CompilerOptions.SrcPath,
|
CompilerOptions.SrcPath:=MergeSearchPaths(CompilerOptions.SrcPath,
|
||||||
|
Loading…
Reference in New Issue
Block a user