mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 19:39:28 +02:00
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:
parent
fbf3e244d0
commit
1903007760
@ -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
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user