IDE: release package editor if not needed any more

git-svn-id: trunk@35089 -
This commit is contained in:
mattias 2012-02-02 16:23:45 +00:00
parent 380da77e72
commit 1f910951e2
4 changed files with 39 additions and 21 deletions

View File

@ -703,6 +703,7 @@ type
function GetUnitPath(RelativeToBaseDir: boolean): string; function GetUnitPath(RelativeToBaseDir: boolean): string;
function GetIncludePath(RelativeToBaseDir: boolean): string; function GetIncludePath(RelativeToBaseDir: boolean): string;
function GetSrcPath(RelativeToBaseDir: boolean): string; function GetSrcPath(RelativeToBaseDir: boolean): string;
function GetFPDocPackageName: string;
function GetLastCompilerParams(o: TPkgOutputDir): string; function GetLastCompilerParams(o: TPkgOutputDir): string;
function NeedsDefineTemplates: boolean; function NeedsDefineTemplates: boolean;
function SubstitutePkgMacros(const s: string; function SubstitutePkgMacros(const s: string;
@ -772,8 +773,6 @@ type
function ProvidesPackage(const AName: string): boolean; function ProvidesPackage(const AName: string): boolean;
// ID // ID
procedure ChangeID(const NewName: string; NewVersion: TPkgVersion); procedure ChangeID(const NewName: string; NewVersion: TPkgVersion);
function GetFPDocPackageName: string;
public public
LastCompile: array[TPkgOutputDir] of TPkgLastCompileStats; LastCompile: array[TPkgOutputDir] of TPkgLastCompileStats;
function GetOutputDirType: TPkgOutputDir; function GetOutputDirType: TPkgOutputDir;

View File

@ -927,6 +927,7 @@ end;
procedure TPackageEditorForm.PackageEditorFormClose(Sender: TObject; procedure TPackageEditorForm.PackageEditorFormClose(Sender: TObject;
var CloseAction: TCloseAction); var CloseAction: TCloseAction);
begin begin
//debugln(['TPackageEditorForm.PackageEditorFormClose ',Caption]);
if LazPackage=nil then exit; if LazPackage=nil then exit;
end; end;
@ -935,19 +936,24 @@ procedure TPackageEditorForm.PackageEditorFormCloseQuery(Sender: TObject;
var var
MsgResult: Integer; MsgResult: Integer;
begin begin
if (LazPackage=nil) or (lpfDestroying in LazPackage.Flags) //debugln(['TPackageEditorForm.PackageEditorFormCloseQuery ',Caption]);
or (LazPackage.ReadOnly) or (not LazPackage.Modified) then exit; if (LazPackage<>nil) and (not (lpfDestroying in LazPackage.Flags))
and (not LazPackage.ReadOnly) and LazPackage.Modified then begin
MsgResult:=MessageDlg(lisPkgMangSavePackage, MsgResult:=MessageDlg(lisPkgMangSavePackage,
Format(lisPckEditPackageHasChangedSavePackage,['"',LazPackage.IDAsString,'"',#13]), Format(lisPckEditPackageHasChangedSavePackage,['"',LazPackage.IDAsString,'"',#13]),
mtConfirmation,[mbYes,mbNo,mbAbort],0); mtConfirmation,[mbYes,mbNo,mbAbort],0);
case MsgResult of case MsgResult of
mrYes: mrYes:
MsgResult:=PackageEditors.SavePackage(LazPackage,false); MsgResult:=PackageEditors.SavePackage(LazPackage,false);
mrNo: mrNo:
LazPackage.UserIgnoreChangeStamp:=LazPackage.ChangeStamp; LazPackage.UserIgnoreChangeStamp:=LazPackage.ChangeStamp;
end;
if MsgResult=mrAbort then CanClose:=false;
end; end;
if MsgResult=mrAbort then CanClose:=false; //debugln(['TPackageEditorForm.PackageEditorFormCloseQuery CanClose=',CanClose,' ',Caption]);
if CanClose then
Application.ReleaseComponent(Self);
end; end;
procedure TPackageEditorForm.RegisteredListBoxDrawItem(Control: TWinControl; procedure TPackageEditorForm.RegisteredListBoxDrawItem(Control: TWinControl;

View File

@ -705,8 +705,10 @@ procedure TLazPackageGraph.Delete(Index: integer);
var var
CurPkg: TLazPackage; CurPkg: TLazPackage;
begin begin
BeginUpdate(true);
CurPkg:=Packages[Index]; CurPkg:=Packages[Index];
if lpfDestroying in CurPkg.Flags then exit;
BeginUpdate(true);
CurPkg.Flags:=CurPkg.Flags+[lpfDestroying]; CurPkg.Flags:=CurPkg.Flags+[lpfDestroying];
CurPkg.DefineTemplates.Active:=false; CurPkg.DefineTemplates.Active:=false;
@ -3128,9 +3130,11 @@ var
begin begin
BeginUpdate(false); BeginUpdate(false);
MarkNeededPackages; MarkNeededPackages;
for i:=FItems.Count-1 downto 0 do begin for i:=FItems.Count-1 downto 0 do
if not (lpfNeeded in Packages[i].Flags) then Delete(i); if not (lpfNeeded in Packages[i].Flags) then begin
end; debugln(['TLazPackageGraph.CloseUnneededPackages Pkg=',Packages[i].Name]);
Delete(i);
end;
EndUpdate; EndUpdate;
end; end;
@ -4865,17 +4869,27 @@ end;
function TLazPackageGraph.PackageIsNeeded(APackage: TLazPackage): boolean; function TLazPackageGraph.PackageIsNeeded(APackage: TLazPackage): boolean;
// check if package is currently in use (installed, autoinstall, editor open, // check if package is currently in use (installed, autoinstall, editor open,
// or used by a needed dependency) // or used by a project)
// !!! it does not check if any needed package needs this package // !!! it does not check if any needed package needs this package
var
ADependency: TPkgDependency;
begin begin
Result:=true; Result:=true;
// check if package is open, installed or will be installed // check if package is open, installed or will be installed
if (APackage.Installed<>pitNope) or (APackage.AutoInstall<>pitNope) if (APackage.Installed<>pitNope) or (APackage.AutoInstall<>pitNope)
or ((APackage.Editor<>nil) and (APackage.Editor.Visible)) or APackage.Modified
or (APackage.Editor<>nil)
or (APackage.HoldPackageCount>0) then or (APackage.HoldPackageCount>0) then
begin begin
exit; exit;
end; end;
// check if used by project
ADependency:=APackage.FirstUsedByDependency;
while ADependency<>nil do begin
if ADependency.Owner is TLazProject then
exit;
ADependency:=ADependency.NextUsedByDependency;
end;
Result:=false; Result:=false;
end; end;

View File

@ -4598,9 +4598,8 @@ end;
function TPkgManager.DoClosePackageEditor(APackage: TLazPackage): TModalResult; function TPkgManager.DoClosePackageEditor(APackage: TLazPackage): TModalResult;
begin begin
if APackage.Editor<>nil then begin if APackage.Editor<>nil then
APackage.Editor.Free; APackage.Editor.Free;
end;
Result:=mrOk; Result:=mrOk;
end; end;