mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-06 04:57:12 +01:00
project groups: fixed mem leaks
git-svn-id: trunk@50415 -
This commit is contained in:
parent
856899df4a
commit
ee04979b7c
@ -49,6 +49,7 @@ type
|
|||||||
public
|
public
|
||||||
procedure LoadTarget(Recursively: boolean); virtual;
|
procedure LoadTarget(Recursively: boolean); virtual;
|
||||||
procedure UnLoadTarget; virtual;
|
procedure UnLoadTarget; virtual;
|
||||||
|
destructor Destroy; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Since a project group iself is also a target, we need a target to represent
|
// Since a project group iself is also a target, we need a target to represent
|
||||||
@ -395,6 +396,7 @@ end;
|
|||||||
|
|
||||||
destructor TIDEProjectGroupManager.Destroy;
|
destructor TIDEProjectGroupManager.Destroy;
|
||||||
begin
|
begin
|
||||||
|
FreeAndNil(FProjectGroup);
|
||||||
FreeAndNil(FOptions);
|
FreeAndNil(FOptions);
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
@ -469,7 +471,7 @@ var
|
|||||||
begin
|
begin
|
||||||
Item:=Sender as TIDEMenuCommand;
|
Item:=Sender as TIDEMenuCommand;
|
||||||
aFilename:=Item.Caption;
|
aFilename:=Item.Caption;
|
||||||
debugln(['TIDEProjectGroupManager.DoOpenRecentClick ',aFilename]);
|
//debugln(['TIDEProjectGroupManager.DoOpenRecentClick ',aFilename]);
|
||||||
LoadProjectGroup(aFilename,[pgloLoadRecursively]);
|
LoadProjectGroup(aFilename,[pgloLoadRecursively]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -523,17 +525,17 @@ begin
|
|||||||
FProjectGroup:=TIDEProjectGroup.Create(nil);
|
FProjectGroup:=TIDEProjectGroup.Create(nil);
|
||||||
FProjectGroup.FileName:=AFileName;
|
FProjectGroup.FileName:=AFileName;
|
||||||
FProjectGroup.LoadFromFile(AOptions);
|
FProjectGroup.LoadFromFile(AOptions);
|
||||||
If not (pgloSkipDialog in AOptions) then
|
if not (pgloSkipDialog in AOptions) then
|
||||||
ShowProjectGroupEditor;
|
ShowProjectGroupEditor;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TIDEProjectGroupManager.SaveProjectGroup;
|
procedure TIDEProjectGroupManager.SaveProjectGroup;
|
||||||
begin
|
begin
|
||||||
If Assigned(FProjectGroup) then
|
if Assigned(FProjectGroup) then
|
||||||
begin
|
begin
|
||||||
If (FProjectGroup.FileName<>'') or GetNewFileName then
|
if (FProjectGroup.FileName<>'') or GetNewFileName then
|
||||||
FProjectGroup.SaveToFile;
|
FProjectGroup.SaveToFile;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TRootProjectGroupTarget }
|
{ TRootProjectGroupTarget }
|
||||||
@ -639,7 +641,7 @@ begin
|
|||||||
Result.FileName:=AFileName;
|
Result.FileName:=AFileName;
|
||||||
FTargets.Add(Result);
|
FTargets.Add(Result);
|
||||||
IncreaseChangeStamp;
|
IncreaseChangeStamp;
|
||||||
If Assigned(FOnTargetAdded) then
|
if Assigned(FOnTargetAdded) then
|
||||||
FOnTargetAdded(Self,Result);
|
FOnTargetAdded(Self,Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -829,7 +831,7 @@ end;
|
|||||||
|
|
||||||
procedure TIDECompileTarget.UnLoadTarget;
|
procedure TIDECompileTarget.UnLoadTarget;
|
||||||
begin
|
begin
|
||||||
if FProjectGroup<>nil then
|
if (FProjectGroup<>nil) and not (Self is TRootProjectGroupTarget) then
|
||||||
FreeAndNil(FProjectGroup);
|
FreeAndNil(FProjectGroup);
|
||||||
if FFiles<>nil then
|
if FFiles<>nil then
|
||||||
FreeAndNil(FFiles);
|
FreeAndNil(FFiles);
|
||||||
@ -837,6 +839,12 @@ begin
|
|||||||
FreeAndNil(FRequiredPackages);
|
FreeAndNil(FRequiredPackages);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
destructor TIDECompileTarget.Destroy;
|
||||||
|
begin
|
||||||
|
UnLoadTarget;
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
function TIDECompileTarget.CompileUsingLazBuild(const AAction: TPGTargetAction
|
function TIDECompileTarget.CompileUsingLazBuild(const AAction: TPGTargetAction
|
||||||
): TPGActionResult;
|
): TPGActionResult;
|
||||||
var
|
var
|
||||||
@ -1010,7 +1018,6 @@ begin
|
|||||||
if (AProject<>nil) and (CompareFilenames(AProject.ProjectInfoFile,Filename)=0)
|
if (AProject<>nil) and (CompareFilenames(AProject.ProjectInfoFile,Filename)=0)
|
||||||
then begin
|
then begin
|
||||||
// load from active project
|
// load from active project
|
||||||
FFiles:=TStringList.Create;
|
|
||||||
for i:=0 to AProject.FileCount-1 do begin
|
for i:=0 to AProject.FileCount-1 do begin
|
||||||
ProjFile:=AProject.Files[i];
|
ProjFile:=AProject.Files[i];
|
||||||
if not ProjFile.IsPartOfProject then continue;
|
if not ProjFile.IsPartOfProject then continue;
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
{
|
{
|
||||||
Todo:
|
Todo:
|
||||||
- ask save on exit
|
|
||||||
- save on save all
|
|
||||||
- close windows on IDE close
|
- close windows on IDE close
|
||||||
- activate project when project is opened
|
- activate project when project is opened
|
||||||
- deactivate project when project is closed
|
- deactivate project when project is closed
|
||||||
@ -277,10 +275,8 @@ procedure TProjectGroupEditorForm.ClearEventCallBacks(AProjectGroup: TProjectGro
|
|||||||
Var
|
Var
|
||||||
PG: TIDEProjectGroup;
|
PG: TIDEProjectGroup;
|
||||||
begin
|
begin
|
||||||
if AProjectGroup is TIDEProjectGroup then
|
debugln(['TProjectGroupEditorForm.ClearEventCallBacks ']);
|
||||||
PG:=TIDEProjectGroup(AProjectGroup)
|
PG:=AProjectGroup as TIDEProjectGroup;
|
||||||
else
|
|
||||||
exit;
|
|
||||||
PG.RemoveAllHandlersOfObject(Self);
|
PG.RemoveAllHandlersOfObject(Self);
|
||||||
PG.OnFileNameChange:=Nil;
|
PG.OnFileNameChange:=Nil;
|
||||||
PG.OnTargetAdded:=Nil;
|
PG.OnTargetAdded:=Nil;
|
||||||
@ -293,10 +289,7 @@ procedure TProjectGroupEditorForm.SetEventCallBacks(AProjectGroup: TProjectGroup
|
|||||||
Var
|
Var
|
||||||
PG: TIDEProjectGroup;
|
PG: TIDEProjectGroup;
|
||||||
begin
|
begin
|
||||||
if AProjectGroup is TIDEProjectGroup then
|
PG:=AProjectGroup as TIDEProjectGroup;
|
||||||
PG:=TIDEProjectGroup(AProjectGroup)
|
|
||||||
else
|
|
||||||
exit;
|
|
||||||
PG.AddHandlerOnDestroy(@OnProjectGroupDestroy);
|
PG.AddHandlerOnDestroy(@OnProjectGroupDestroy);
|
||||||
PG.OnFileNameChange:=@OnProjectGroupFileNameChanged;
|
PG.OnFileNameChange:=@OnProjectGroupFileNameChanged;
|
||||||
PG.OnTargetAdded:=@OnTargetAdded;
|
PG.OnTargetAdded:=@OnTargetAdded;
|
||||||
@ -307,7 +300,7 @@ end;
|
|||||||
|
|
||||||
procedure TProjectGroupEditorForm.SetProjectGroup(AValue: TProjectGroup);
|
procedure TProjectGroupEditorForm.SetProjectGroup(AValue: TProjectGroup);
|
||||||
begin
|
begin
|
||||||
debugln(['TProjectGroupEditorForm.SetProjectGroup START ',FProjectGroup=AValue]);
|
debugln(['TProjectGroupEditorForm.SetProjectGroup START ',FProjectGroup=AValue,' new=',DbgSName(AValue)]);
|
||||||
if FProjectGroup=AValue then Exit;
|
if FProjectGroup=AValue then Exit;
|
||||||
if ProjectGroup<>nil then
|
if ProjectGroup<>nil then
|
||||||
begin
|
begin
|
||||||
@ -492,6 +485,8 @@ end;
|
|||||||
|
|
||||||
procedure TProjectGroupEditorForm.FormDestroy(Sender: TObject);
|
procedure TProjectGroupEditorForm.FormDestroy(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
|
debugln(['TProjectGroupEditorForm.FormDestroy ',ProjectGroup<>nil]);
|
||||||
|
ProjectGroup:=nil;
|
||||||
if ProjectGroupEditorForm=Self then
|
if ProjectGroupEditorForm=Self then
|
||||||
ProjectGroupEditorForm:=nil;
|
ProjectGroupEditorForm:=nil;
|
||||||
end;
|
end;
|
||||||
|
|||||||
@ -276,8 +276,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TProjectGroup.Destroy;
|
destructor TProjectGroup.Destroy;
|
||||||
|
var
|
||||||
|
HandlerType: TProjectGroupHandler;
|
||||||
begin
|
begin
|
||||||
DoCallNotifyHandler(pghDestroy,Self);
|
DoCallNotifyHandler(pghDestroy,Self);
|
||||||
|
for HandlerType:=Low(FHandlers) to High(FHandlers) do
|
||||||
|
FreeAndNil(FHandlers[HandlerType]);
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
@ -88,5 +88,8 @@ begin
|
|||||||
SetProjectGroupEditorCallBack;
|
SetProjectGroupEditorCallBack;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
finalization
|
||||||
|
FreeAndNil(IDEProjectGroupManager);
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user