mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-17 15:09:46 +02:00
IDE: release package editor if not needed any more
git-svn-id: trunk@35089 -
This commit is contained in:
parent
380da77e72
commit
1f910951e2
@ -703,6 +703,7 @@ type
|
||||
function GetUnitPath(RelativeToBaseDir: boolean): string;
|
||||
function GetIncludePath(RelativeToBaseDir: boolean): string;
|
||||
function GetSrcPath(RelativeToBaseDir: boolean): string;
|
||||
function GetFPDocPackageName: string;
|
||||
function GetLastCompilerParams(o: TPkgOutputDir): string;
|
||||
function NeedsDefineTemplates: boolean;
|
||||
function SubstitutePkgMacros(const s: string;
|
||||
@ -772,8 +773,6 @@ type
|
||||
function ProvidesPackage(const AName: string): boolean;
|
||||
// ID
|
||||
procedure ChangeID(const NewName: string; NewVersion: TPkgVersion);
|
||||
|
||||
function GetFPDocPackageName: string;
|
||||
public
|
||||
LastCompile: array[TPkgOutputDir] of TPkgLastCompileStats;
|
||||
function GetOutputDirType: TPkgOutputDir;
|
||||
|
@ -927,6 +927,7 @@ end;
|
||||
procedure TPackageEditorForm.PackageEditorFormClose(Sender: TObject;
|
||||
var CloseAction: TCloseAction);
|
||||
begin
|
||||
//debugln(['TPackageEditorForm.PackageEditorFormClose ',Caption]);
|
||||
if LazPackage=nil then exit;
|
||||
end;
|
||||
|
||||
@ -935,19 +936,24 @@ procedure TPackageEditorForm.PackageEditorFormCloseQuery(Sender: TObject;
|
||||
var
|
||||
MsgResult: Integer;
|
||||
begin
|
||||
if (LazPackage=nil) or (lpfDestroying in LazPackage.Flags)
|
||||
or (LazPackage.ReadOnly) or (not LazPackage.Modified) then exit;
|
||||
//debugln(['TPackageEditorForm.PackageEditorFormCloseQuery ',Caption]);
|
||||
if (LazPackage<>nil) and (not (lpfDestroying in LazPackage.Flags))
|
||||
and (not LazPackage.ReadOnly) and LazPackage.Modified then begin
|
||||
|
||||
MsgResult:=MessageDlg(lisPkgMangSavePackage,
|
||||
Format(lisPckEditPackageHasChangedSavePackage,['"',LazPackage.IDAsString,'"',#13]),
|
||||
mtConfirmation,[mbYes,mbNo,mbAbort],0);
|
||||
case MsgResult of
|
||||
mrYes:
|
||||
MsgResult:=PackageEditors.SavePackage(LazPackage,false);
|
||||
mrNo:
|
||||
LazPackage.UserIgnoreChangeStamp:=LazPackage.ChangeStamp;
|
||||
MsgResult:=MessageDlg(lisPkgMangSavePackage,
|
||||
Format(lisPckEditPackageHasChangedSavePackage,['"',LazPackage.IDAsString,'"',#13]),
|
||||
mtConfirmation,[mbYes,mbNo,mbAbort],0);
|
||||
case MsgResult of
|
||||
mrYes:
|
||||
MsgResult:=PackageEditors.SavePackage(LazPackage,false);
|
||||
mrNo:
|
||||
LazPackage.UserIgnoreChangeStamp:=LazPackage.ChangeStamp;
|
||||
end;
|
||||
if MsgResult=mrAbort then CanClose:=false;
|
||||
end;
|
||||
if MsgResult=mrAbort then CanClose:=false;
|
||||
//debugln(['TPackageEditorForm.PackageEditorFormCloseQuery CanClose=',CanClose,' ',Caption]);
|
||||
if CanClose then
|
||||
Application.ReleaseComponent(Self);
|
||||
end;
|
||||
|
||||
procedure TPackageEditorForm.RegisteredListBoxDrawItem(Control: TWinControl;
|
||||
|
@ -705,8 +705,10 @@ procedure TLazPackageGraph.Delete(Index: integer);
|
||||
var
|
||||
CurPkg: TLazPackage;
|
||||
begin
|
||||
BeginUpdate(true);
|
||||
CurPkg:=Packages[Index];
|
||||
if lpfDestroying in CurPkg.Flags then exit;
|
||||
|
||||
BeginUpdate(true);
|
||||
CurPkg.Flags:=CurPkg.Flags+[lpfDestroying];
|
||||
CurPkg.DefineTemplates.Active:=false;
|
||||
|
||||
@ -3128,9 +3130,11 @@ var
|
||||
begin
|
||||
BeginUpdate(false);
|
||||
MarkNeededPackages;
|
||||
for i:=FItems.Count-1 downto 0 do begin
|
||||
if not (lpfNeeded in Packages[i].Flags) then Delete(i);
|
||||
end;
|
||||
for i:=FItems.Count-1 downto 0 do
|
||||
if not (lpfNeeded in Packages[i].Flags) then begin
|
||||
debugln(['TLazPackageGraph.CloseUnneededPackages Pkg=',Packages[i].Name]);
|
||||
Delete(i);
|
||||
end;
|
||||
EndUpdate;
|
||||
end;
|
||||
|
||||
@ -4865,17 +4869,27 @@ end;
|
||||
|
||||
function TLazPackageGraph.PackageIsNeeded(APackage: TLazPackage): boolean;
|
||||
// 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
|
||||
var
|
||||
ADependency: TPkgDependency;
|
||||
begin
|
||||
Result:=true;
|
||||
// check if package is open, installed or will be installed
|
||||
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
|
||||
begin
|
||||
exit;
|
||||
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;
|
||||
end;
|
||||
|
||||
|
@ -4598,9 +4598,8 @@ end;
|
||||
|
||||
function TPkgManager.DoClosePackageEditor(APackage: TLazPackage): TModalResult;
|
||||
begin
|
||||
if APackage.Editor<>nil then begin
|
||||
if APackage.Editor<>nil then
|
||||
APackage.Editor.Free;
|
||||
end;
|
||||
Result:=mrOk;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user