CodeTools: create new callback FindIncFileInCfgCache in basiccodetools.pas filled by codetoolmanager.pas to omit compilicated unit dependencies introduced in linkscanner.pas by uses section (for modules: CodeToolManager and DefineTemplates) in implementation section (that was the reason of AV on IDE exit and memory leaks, fix for mantis #31575, #31580)

git-svn-id: trunk@54461 -
This commit is contained in:
hnb 2017-03-21 23:06:36 +00:00
parent fbf3e244d0
commit 1903007760
3 changed files with 25 additions and 17 deletions

View File

@ -268,6 +268,10 @@ function CompareUnitNameAndUnitFileInfo(UnitnamePAnsiString,
function CompareNameSpaceAndNameSpaceInfo(NamespacePAnsiString, function CompareNameSpaceAndNameSpaceInfo(NamespacePAnsiString,
NamespaceInfo: Pointer): integer; NamespaceInfo: Pointer): integer;
// function filled by CodeToolManager to find inc files
var
FindIncFileInCfgCache: function(const Name: string; out ExpFilename: string): boolean;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// functions / procedures // functions / procedures

View File

@ -6471,9 +6471,24 @@ end;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
function FindIncFileInCfgCache(const Name: string; out ExpFilename: string): boolean;
var
CfgCache: TFPCTargetConfigCache;
UnitSet: TFPCUnitSetCache;
begin
// search the include file in directories defines in fpc.cfg (by -Fi option)
UnitSet:=CodeToolBoss.GetUnitSetForDirectory('');
if UnitSet<>nil then begin
CfgCache:=UnitSet.GetConfigCache(false);
Result:=Assigned(CfgCache) and Assigned(CfgCache.Includes)
and CfgCache.Includes.GetString(Name,ExpFilename);
end;
end;
initialization initialization
CodeToolBoss:=TCodeToolManager.Create; CodeToolBoss:=TCodeToolManager.Create;
OnFindOwnerOfCodeTreeNode:=@GetOwnerForCodeTreeNode; OnFindOwnerOfCodeTreeNode:=@GetOwnerForCodeTreeNode;
BasicCodeTools.FindIncFileInCfgCache:=@FindIncFileInCfgCache;
finalization finalization

View File

@ -829,9 +829,6 @@ function dbgs(s: TLSDirectiveKind): string; overload;
implementation implementation
uses
CodeToolManager, DefineTemplates;
// useful procs ---------------------------------------------------------------- // useful procs ----------------------------------------------------------------
function IndexOfCodeInUniqueList(ACode: Pointer; function IndexOfCodeInUniqueList(ACode: Pointer;
@ -3970,9 +3967,6 @@ var
end; end;
function SearchCasedInIncPath(const RelFilename: string): boolean; function SearchCasedInIncPath(const RelFilename: string): boolean;
var
CfgCache: TFPCTargetConfigCache;
UnitSet: TFPCUnitSetCache;
begin begin
if FilenameIsAbsolute(FMainSourceFilename) then begin if FilenameIsAbsolute(FMainSourceFilename) then begin
// main source has absolute filename // main source has absolute filename
@ -3996,17 +3990,12 @@ var
if Result then exit; if Result then exit;
end; end;
// then search the include file from fpc.cfg (-Fi option) // then search the include file in directories defines in fpc.cfg (by -Fi option)
UnitSet:=CodeToolBoss.GetUnitSetForDirectory(''); if FindIncFileInCfgCache(AFilename,ExpFilename) then
if UnitSet<>nil then begin begin
CfgCache:=UnitSet.GetConfigCache(false); NewCode:=LoadSourceCaseLoUp(ExpFilename);
if Assigned(CfgCache) and Assigned(CfgCache.Includes) Result:=(NewCode<>nil);
and CfgCache.Includes.GetString(AFilename,ExpFilename) then if Result then exit;
begin
NewCode:=LoadSourceCaseLoUp(ExpFilename);
Result:=(NewCode<>nil);
if Result then exit;
end;
end; end;
// then search the include file in the include path // then search the include file in the include path