IDE: add to project: add relative unit path, bug #17021

git-svn-id: trunk@26811 -
This commit is contained in:
mattias 2010-07-24 14:51:47 +00:00
parent 4fcf37a14d
commit 0bfff4fa03

View File

@ -15961,6 +15961,7 @@ var
Owners: TFPList; Owners: TFPList;
i: Integer; i: Integer;
APackage: TLazPackage; APackage: TLazPackage;
ShortDir: String;
begin begin
DependencyAdded:=false; DependencyAdded:=false;
if UnitInfo.IsVirtual then exit; if UnitInfo.IsVirtual then exit;
@ -15991,14 +15992,16 @@ begin
end; end;
end; end;
// unit is not in a package => extend unit path // unit is not in a package => extend unit path
ShortDir:=CurDirectory;
if (not Project1.IsVirtual) then
ShortDir:=CreateRelativePath(ShortDir,Project1.ProjectDirectory);
if MessageDlg(lisAddToUnitSearchPath, if MessageDlg(lisAddToUnitSearchPath,
Format(lisTheNewUnitIsNotYetInTheUnitSearchPathAddDirectory, [ Format(lisTheNewUnitIsNotYetInTheUnitSearchPathAddDirectory, [
#13, CurDirectory]), #13, CurDirectory]),
mtConfirmation,[mbYes,mbNo],0)=mrYes mtConfirmation,[mbYes,mbNo],0)=mrYes
then begin then begin
Project1.CompilerOptions.OtherUnitFiles:= Project1.CompilerOptions.OtherUnitFiles:=
MergeSearchPaths(Project1.CompilerOptions.OtherUnitFiles, MergeSearchPaths(Project1.CompilerOptions.OtherUnitFiles,ShortDir);
CurDirectory);
end; end;
end; end;
end; end;
@ -16013,9 +16016,11 @@ var
DependencyAdded: boolean; DependencyAdded: boolean;
begin begin
Result:=mrOk; Result:=mrOk;
//debugln(['TMainIDE.ProjInspectorAddUnitToProject ',AnUnitInfo.Filename]);
BeginCodeTool(ActiveSourceEditor,ActiveUnitInfo,[]); BeginCodeTool(ActiveSourceEditor,ActiveUnitInfo,[]);
AnUnitInfo.IsPartOfProject:=true; AnUnitInfo.IsPartOfProject:=true;
CheckUnitDirIsInSearchPath(AnUnitInfo,false,DependencyAdded); if FilenameIsPascalUnit(AnUnitInfo.Filename) then
CheckUnitDirIsInSearchPath(AnUnitInfo,false,DependencyAdded);
if FilenameIsPascalUnit(AnUnitInfo.Filename) if FilenameIsPascalUnit(AnUnitInfo.Filename)
and (pfMainUnitHasUsesSectionForAllUnits in Project1.Flags) and (pfMainUnitHasUsesSectionForAllUnits in Project1.Flags)
then begin then begin