IDE: Free the new IDE builder object only at the very end. It is used longer than it first appears.

git-svn-id: trunk@44031 -
This commit is contained in:
juha 2014-02-12 16:40:10 +00:00
parent 197fad765b
commit 3407665a5d

View File

@ -1652,6 +1652,7 @@ begin
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TMainIDE.Destroy C ');{$ENDIF} {$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TMainIDE.Destroy C ');{$ENDIF}
FreeThenNil(IDEProtocolOpts); FreeThenNil(IDEProtocolOpts);
FreeThenNil(fBuilder);
DebugLn('[TMainIDE.Destroy] END'); DebugLn('[TMainIDE.Destroy] END');
end; end;
@ -4531,6 +4532,7 @@ var
FoundProfToBuild: Boolean; FoundProfToBuild: Boolean;
s: String; s: String;
begin begin
if ToolStatus<>itNone then exit;
with MiscellaneousOptions do begin with MiscellaneousOptions do begin
FoundProfToBuild:=False; FoundProfToBuild:=False;
s:=sLineBreak+sLineBreak; s:=sLineBreak+sLineBreak;
@ -4559,39 +4561,36 @@ var
DlgResult: TModalResult; DlgResult: TModalResult;
begin begin
if ToolStatus<>itNone then exit; if ToolStatus<>itNone then exit;
if fBuilder=Nil then
fBuilder:=TLazarusBuilder.Create; // Will be freed in the very end.
MainBuildBoss.SetBuildTargetIDE; MainBuildBoss.SetBuildTargetIDE;
fBuilder := TLazarusBuilder.Create; // Build profile is not known yet.
try try
try DlgResult:=fBuilder.ShowConfigureBuildLazarusDlg(MiscellaneousOptions.BuildLazProfiles);
DlgResult:=fBuilder.ShowConfigureBuildLazarusDlg(MiscellaneousOptions.BuildLazProfiles);
finally
MainBuildBoss.SetBuildTargetProject1(true);
end;
if DlgResult in [mrOk,mrYes,mrAll] then begin
MiscellaneousOptions.Save;
IncreaseCompilerParseStamp;
if DlgResult=mrAll then
DoBuildAdvancedLazarus(MiscellaneousOptions.BuildLazProfiles.Selected)
else if DlgResult=mrYes then begin
LazSrcTemplate:=
CodeToolBoss.DefineTree.FindDefineTemplateByName(StdDefTemplLazarusSources,true);
if Assigned(LazSrcTemplate) then begin
LazSrcDirTemplate:=LazSrcTemplate.FindChildByName(StdDefTemplLazarusSrcDir);
if Assigned(LazSrcDirTemplate) then begin
CmdLineDefines:=CodeToolBoss.DefinePool.CreateFPCCommandLineDefines(
StdDefTemplLazarusBuildOpts,
MiscellaneousOptions.BuildLazProfiles.Current.ExtraOptions,
true,CodeToolsOpts);
CodeToolBoss.DefineTree.ReplaceChild(LazSrcDirTemplate,CmdLineDefines,
StdDefTemplLazarusBuildOpts);
end;
end;
DoBuildLazarus([]);
end;
end;
finally finally
FreeAndNil(fBuilder); MainBuildBoss.SetBuildTargetProject1(true);
end;
if DlgResult in [mrOk,mrYes,mrAll] then begin
MiscellaneousOptions.Save;
IncreaseCompilerParseStamp;
if DlgResult=mrAll then
DoBuildAdvancedLazarus(MiscellaneousOptions.BuildLazProfiles.Selected)
else if DlgResult=mrYes then begin
LazSrcTemplate:=
CodeToolBoss.DefineTree.FindDefineTemplateByName(StdDefTemplLazarusSources,true);
if Assigned(LazSrcTemplate) then begin
LazSrcDirTemplate:=LazSrcTemplate.FindChildByName(StdDefTemplLazarusSrcDir);
if Assigned(LazSrcDirTemplate) then begin
CmdLineDefines:=CodeToolBoss.DefinePool.CreateFPCCommandLineDefines(
StdDefTemplLazarusBuildOpts,
MiscellaneousOptions.BuildLazProfiles.Current.ExtraOptions,
true,CodeToolsOpts);
CodeToolBoss.DefineTree.ReplaceChild(LazSrcDirTemplate,CmdLineDefines,
StdDefTemplLazarusBuildOpts);
end;
end;
DoBuildLazarus([]);
end;
end; end;
end; end;
@ -7517,7 +7516,6 @@ var
FPCVersion, FPCRelease, FPCPatch: integer; FPCVersion, FPCRelease, FPCPatch: integer;
PkgCompileFlags: TPkgCompileFlags; PkgCompileFlags: TPkgCompileFlags;
ProfileChanged: Boolean; ProfileChanged: Boolean;
BuilderCreated: Boolean;
begin begin
if ToolStatus<>itNone then begin if ToolStatus<>itNone then begin
IDEMessageDialog(lisNotNow,lisYouCanNotBuildLazarusWhileDebuggingOrCompiling, IDEMessageDialog(lisNotNow,lisYouCanNotBuildLazarusWhileDebuggingOrCompiling,
@ -7532,8 +7530,7 @@ begin
exit; exit;
end; end;
BuilderCreated := fBuilder = Nil; if fBuilder=Nil then
if BuilderCreated then
fBuilder:=TLazarusBuilder.Create; fBuilder:=TLazarusBuilder.Create;
{$IFNDEF EnableNewExtTools} {$IFNDEF EnableNewExtTools}
MessagesView.BeginBlock; MessagesView.BeginBlock;
@ -7617,8 +7614,6 @@ begin
if ProfileChanged then if ProfileChanged then
MiscellaneousOptions.Save; MiscellaneousOptions.Save;
finally finally
if BuilderCreated then
FreeAndNil(fBuilder);
MainBuildBoss.SetBuildTargetProject1(true); MainBuildBoss.SetBuildTargetProject1(true);
DoCheckFilesOnDisk; DoCheckFilesOnDisk;
{$IFNDEF EnableNewExtTools} {$IFNDEF EnableNewExtTools}