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,
NamespaceInfo: Pointer): integer;
// function filled by CodeToolManager to find inc files
var
FindIncFileInCfgCache: function(const Name: string; out ExpFilename: string): boolean;
//-----------------------------------------------------------------------------
// 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
CodeToolBoss:=TCodeToolManager.Create;
OnFindOwnerOfCodeTreeNode:=@GetOwnerForCodeTreeNode;
BasicCodeTools.FindIncFileInCfgCache:=@FindIncFileInCfgCache;
finalization

View File

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