IDE: package editor: publish: disable if units/includes outside pkg dir

git-svn-id: trunk@55096 -
This commit is contained in:
mattias 2017-05-26 11:39:42 +00:00
parent 9b548421fa
commit 626736e5e2
2 changed files with 24 additions and 14 deletions

View File

@ -3439,10 +3439,10 @@ var
end;
begin
//DebugLn('TLazSourceFileManager.PublishModule A');
//DebugLn('Hint: (lazarus) [TLazSourceFileManager.PublishModule] START');
Result:=mrCancel;
// do not delete project files
// do not delete project/package files
DestDir:=TrimAndExpandDirectory(DestDirectory);
SrcDir:=TrimAndExpandDirectory(SrcDirectory);
if (DestDir='') then begin
@ -3452,7 +3452,7 @@ begin
Result:=mrCancel;
exit;
end;
//DebugLn('TLazSourceFileManager.PublishModule A SrcDir="',SrcDir,'" DestDir="',DestDir,'"');
//DebugLn('Hint: (lazarus) [TLazSourceFileManager.PublishModule] SrcDir="',SrcDir,'" DestDir="',DestDir,'"');
if CompareFilenames(SrcDir,DestDir)=0
then begin
IDEMessageDialog(lisInvalidPublishingDirectory,
@ -3471,7 +3471,7 @@ begin
end;
SplitCmdLine(CommandAfter,CmdAfterExe,CmdAfterParams);
if (CmdAfterExe<>'') then begin
//DebugLn('TLazSourceFileManager.PublishModule A CmdAfterExe="',CmdAfterExe,'"');
//DebugLn('Hint: (lazarus) [TLazSourceFileManager.PublishModule] CmdAfterExe="',CmdAfterExe,'"');
// first look in the project directory
TempCmd:=CmdAfterExe;
if not FilenameIsAbsolute(TempCmd) then
@ -3494,7 +3494,7 @@ begin
// clear destination directory
if DirPathExists(DestDir) then begin
// ask user, if destination can be delete
// ask user, if destination can be deleted
if IDEMessageDialog(lisClearDirectory,
Format(lisInOrderToCreateACleanCopyOfTheProjectPackageAllFil,
[LineEnding+LineEnding, DestDir]),
@ -3514,7 +3514,7 @@ begin
// copy the directory
if not CopyDirectoryWithMethods(SrcDir,DestDir,@OnCopyFile,@OnCopyError,Options) then
begin
debugln('TLazSourceFileManager.PublishModule CopyDirectoryWithMethods failed');
debugln('Hint: (lazarus) [TLazSourceFileManager.PublishModule] CopyDirectoryWithMethods failed');
Result:=mrCancel;
exit;
end;
@ -3528,7 +3528,7 @@ begin
+pwfSkipSessionInfo+[pwfIgnoreModified],
NewProjectFilename,nil);
if Result<>mrOk then begin
debugln('TLazSourceFileManager.PublishModule CurProject.WriteProject failed');
debugln('Hint: (lazarus) [TLazSourceFileManager.PublishModule] CurProject.WriteProject failed');
exit;
end;
end;

View File

@ -364,7 +364,7 @@ type
procedure DoShowMissingFiles;
procedure DoMoveCurrentFile(Offset: integer);
procedure DoMoveDependency(Offset: integer);
procedure DoPublishProject;
procedure DoPublishPackage;
procedure DoEditVirtualUnit;
procedure DoExpandCollapseDirectory(ExpandIt: Boolean);
procedure DoUseUnitsInDirectory(Use: boolean);
@ -645,7 +645,7 @@ end;
procedure TPackageEditorForm.PublishClick(Sender: TObject);
begin
DoPublishProject;
DoPublishPackage;
end;
procedure TPackageEditorForm.ReAddMenuItemClick(Sender: TObject);
@ -924,8 +924,6 @@ begin
end;
procedure TPackageEditorForm.MorePopupMenuPopup(Sender: TObject);
var
Writable: Boolean;
procedure SetItem(Item: TIDEMenuCommand; AnOnClick: TNotifyEvent;
aShow: boolean = true; AEnable: boolean = true);
@ -936,6 +934,10 @@ var
Item.Enabled:=AEnable;
end;
var
Writable, CanPublish: Boolean;
pcos: TParsedCompilerOptString;
CurrentPath: String;
begin
PackageEditorMenuRoot.MenuItem:=MorePopupMenu.Items;
//PackageEditorMenuRoot.BeginUpdate;
@ -953,8 +955,16 @@ begin
SetItem(PkgEditMenuSaveAs,@SaveAsClick,true,true);
SetItem(PkgEditMenuRevert,@RevertClick,true,
(not LazPackage.IsVirtual) and FileExistsUTF8(LazPackage.Filename));
SetItem(PkgEditMenuPublish,@PublishClick,true,
(not LazPackage.Missing) and LazPackage.HasDirectory);
CanPublish:=(not LazPackage.Missing) and LazPackage.HasDirectory;
for pcos in [pcosUnitPath,pcosIncludePath] do
begin
CurrentPath:=LazPackage.CompilerOptions.ParsedOpts.GetParsedValue(pcos);
CurrentPath:=CreateRelativeSearchPath(CurrentPath,LazPackage.DirectoryExpanded);
//debugln(['TPackageEditorForm.MorePopupMenuPopup Unit=',CurrentPath]);
if Pos('..',CurrentPath)>0 then
CanPublish:=false;
end;
SetItem(PkgEditMenuPublish,@PublishClick,true,CanPublish);
// under section PkgEditMenuSectionCompile
SetItem(PkgEditMenuCompile,@CompileBitBtnClick,true,CompileBitBtn.Enabled);
@ -3146,7 +3156,7 @@ begin
UpdateAll(false);
end;
procedure TPackageEditorForm.DoPublishProject;
procedure TPackageEditorForm.DoPublishPackage;
begin
PackageEditors.PublishPackage(LazPackage);
end;