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