diff --git a/compiler/fmodule.pas b/compiler/fmodule.pas index 34ceef702e..575ad4e8f4 100644 --- a/compiler/fmodule.pas +++ b/compiler/fmodule.pas @@ -163,6 +163,7 @@ interface localsymtable : TSymtable;{ pointer to the local symtable of this unit } globalmacrosymtable, { pointer to the global macro symtable of this unit } localmacrosymtable : TSymtable;{ pointer to the local macro symtable of this unit } + mainscanner : TObject; { scanner object used } scanner : TObject; { scanner object used } procinfo : TObject; { current procedure being compiled } asmdata : TObject; { Assembler data } @@ -347,7 +348,7 @@ implementation current_asmdata:=tasmdata(current_module.asmdata); current_debuginfo:=tdebuginfo(current_module.debuginfo); { restore scanner and file positions } - current_scanner:=tscannerfile(current_module.scanner); + set_current_scanner(tscannerfile(current_module.scanner),false); if assigned(current_scanner) then begin current_scanner.tempopeninputfile; @@ -363,7 +364,7 @@ implementation else begin current_asmdata:=nil; - current_scanner:=nil; + set_current_scanner(nil,false); current_debuginfo:=nil; end; end; @@ -682,8 +683,9 @@ implementation { also update current_scanner if it was pointing to this module } if current_scanner=tscannerfile(scanner) then - current_scanner:=nil; - tscannerfile(scanner).free; + set_current_scanner(nil,false); + freeandnil(scanner); + end; if assigned(asmdata) then begin @@ -784,9 +786,8 @@ implementation { also update current_scanner if it was pointing to this module } if current_scanner=tscannerfile(scanner) then - current_scanner:=nil; - tscannerfile(scanner).free; - scanner:=nil; + set_current_scanner(nil,false); + freeandnil(scanner); end; if assigned(procinfo) then begin @@ -1152,8 +1153,8 @@ implementation if assigned(scanner) then begin if current_scanner=tscannerfile(scanner) then - current_scanner:=nil; - tscannerfile(scanner).free; + set_current_scanner(nil,false); + FreeAndNil(scanner); scanner:=nil; end; diff --git a/compiler/globstat.pas b/compiler/globstat.pas index 5774572b16..6f886e3d7b 100644 --- a/compiler/globstat.pas +++ b/compiler/globstat.pas @@ -151,7 +151,7 @@ uses current_module:=old_current_module; {!} current_asmdata:=old_asmdata; current_debuginfo:=old_debuginfo; - current_scanner:=old_scanner; + set_current_scanner(old_scanner,False); parser_current_file:=old_parser_file; end; end;