mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-18 05:39:26 +02:00
pastojs: fixed mem leaks
git-svn-id: trunk@39459 -
This commit is contained in:
parent
1a9c7021e4
commit
14af86bd1c
@ -14433,7 +14433,7 @@ begin
|
||||
|
||||
// set ancestor
|
||||
aClass.AncestorType := DestType;
|
||||
{$IFDEF CheckPasTreeRefCount}DestType.ChangeRefId('TPasAliasType.DestType','TPasClassType.AncestorType');{$ENDIF}
|
||||
{$IFDEF CheckPasTreeRefCount}DestType.ChangeRefId('ResolveTypeReference','TPasClassType.AncestorType');{$ENDIF}
|
||||
FinishScope(stAncestors,aClass);
|
||||
end;
|
||||
end;
|
||||
|
@ -776,6 +776,8 @@ begin
|
||||
FreeAndNil(FScanner);
|
||||
FreeAndNil(FFileResolver);
|
||||
FreeAndNil(FPasResolver);
|
||||
if FPasModule<>nil then
|
||||
FPasModule.ReleaseUsedUnits;
|
||||
ReleaseAndNil(TPasElement(FPasModule){$IFDEF CheckPasTreeRefCount},'CreateElement'{$ENDIF});
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
@ -4398,10 +4398,7 @@ var
|
||||
Scope: TPasPropertyScope absolute Data;
|
||||
begin
|
||||
if RefEl is TPasProperty then
|
||||
begin
|
||||
Scope.AncestorProp:=TPasProperty(RefEl);
|
||||
RefEl.AddRef{$IFDEF CheckPasTreeRefCount}('TPasPropertyScope.AncestorProp'){$ENDIF};
|
||||
end
|
||||
Scope.AncestorProp:=TPasProperty(RefEl)
|
||||
else
|
||||
RaiseMsg(20180213214723,Scope.Element,GetObjName(RefEl));
|
||||
end;
|
||||
|
@ -1137,7 +1137,7 @@ end;
|
||||
procedure TCustomTestModule.SetUp;
|
||||
begin
|
||||
{$IFDEF EnablePasTreeGlobalRefCount}
|
||||
FElementRefCountAtSetup:=FModule.GlobalRefCount;
|
||||
FElementRefCountAtSetup:=TPasElement.GlobalRefCount;
|
||||
{$ENDIF}
|
||||
inherited SetUp;
|
||||
FSkipTests:=false;
|
||||
@ -1246,7 +1246,7 @@ begin
|
||||
El:=El.NextRefEl;
|
||||
end;
|
||||
{$ENDIF}
|
||||
//Halt;
|
||||
Halt;
|
||||
Fail('TCustomTestModule.TearDown Was='+IntToStr(FElementRefCountAtSetup)+' Now='+IntToStr(TPasElement.GlobalRefCount));
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
@ -27,7 +27,8 @@ interface
|
||||
uses
|
||||
Classes, SysUtils, contnrs,
|
||||
fpcunit, testregistry,
|
||||
PScanner, Pas2jsFileUtils, Pas2jsCompiler, Pas2jsFileCache, Pas2jsLogger,
|
||||
PScanner, PasTree, PasResolveEval,
|
||||
Pas2jsFileUtils, Pas2jsCompiler, Pas2jsFileCache, Pas2jsLogger,
|
||||
tcmodules;
|
||||
|
||||
type
|
||||
@ -84,6 +85,9 @@ type
|
||||
FFiles: TObjectList; // list of TCLIFile
|
||||
FLogMsgs: TObjectList; // list ot TCLILogMsg
|
||||
FParams: TStringList;
|
||||
{$IFDEF EnablePasTreeGlobalRefCount}
|
||||
FElementRefCountAtSetup: int64;
|
||||
{$ENDIF}
|
||||
function GetExitCode: integer;
|
||||
function GetFiles(Index: integer): TCLIFile;
|
||||
function GetLogMsgs(Index: integer): TCLILogMsg;
|
||||
@ -211,6 +215,9 @@ end;
|
||||
|
||||
procedure TCustomTestCLI.SetUp;
|
||||
begin
|
||||
{$IFDEF EnablePasTreeGlobalRefCount}
|
||||
FElementRefCountAtSetup:=TPasElement.GlobalRefCount;
|
||||
{$ENDIF}
|
||||
inherited SetUp;
|
||||
FDefaultFileAge:=DateTimeToFileDate(Now);
|
||||
{$IFDEF Windows}
|
||||
@ -228,6 +235,11 @@ begin
|
||||
end;
|
||||
|
||||
procedure TCustomTestCLI.TearDown;
|
||||
{$IFDEF CheckPasTreeRefCount}
|
||||
var
|
||||
El: TPasElement;
|
||||
i: integer;
|
||||
{$ENDIF}
|
||||
begin
|
||||
FreeAndNil(FCompiler);
|
||||
FParams.Clear;
|
||||
@ -239,6 +251,24 @@ begin
|
||||
FErrorCol:=0;
|
||||
FErrorNumber:=0;
|
||||
inherited TearDown;
|
||||
{$IFDEF EnablePasTreeGlobalRefCount}
|
||||
if FElementRefCountAtSetup<>TPasElement.GlobalRefCount then
|
||||
begin
|
||||
writeln('TCustomTestCLI.TearDown GlobalRefCount Was='+IntToStr(FElementRefCountAtSetup)+' Now='+IntToStr(TPasElement.GlobalRefCount));
|
||||
{$IFDEF CheckPasTreeRefCount}
|
||||
El:=TPasElement.FirstRefEl;
|
||||
while El<>nil do
|
||||
begin
|
||||
writeln(' ',GetObjName(El),' RefIds.Count=',El.RefIds.Count,':');
|
||||
for i:=0 to El.RefIds.Count-1 do
|
||||
writeln(' ',El.RefIds[i]);
|
||||
El:=El.NextRefEl;
|
||||
end;
|
||||
{$ENDIF}
|
||||
Halt;
|
||||
Fail('TCustomTestCLI.TearDown Was='+IntToStr(FElementRefCountAtSetup)+' Now='+IntToStr(TPasElement.GlobalRefCount));
|
||||
end;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure TCustomTestCLI.DoLog(Sender: TObject; const Msg: String);
|
||||
|
Loading…
Reference in New Issue
Block a user