fix open file leak when running --debugger:native (#13832)

This commit is contained in:
Timothee Cour 2020-04-01 08:48:17 -07:00 • committed by GitHub
commit d3020af44d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 6 deletions

View file

@ -1924,8 +1924,8 @@ proc shouldRecompile(m: BModule; code: Rope, cfile: Cfile): bool =
# it would generate multiple 'main' procs, for instance.
proc writeModule(m: BModule, pending: bool) =
template onExit() = close(m.ndi, m.config)
let cfile = getCFile(m)
if true or optForceFullMake in m.config.globalOptions:
if moduleHasChanged(m.g.graph, m.module):
genInitCode(m)
@ -1943,6 +1943,7 @@ proc writeModule(m: BModule, pending: bool) =
when hasTinyCBackend:
if conf.cmd == cmdRun:
tccgen.compileCCode($code)
onExit()
return
if not shouldRecompile(m, code, cf): cf.flags = {CfileFlag.Cached}
@ -1966,7 +1967,7 @@ proc writeModule(m: BModule, pending: bool) =
obj: completeCfilePath(m.config, toObjFile(m.config, cfile)), flags: {})
if not fileExists(cf.obj): cf.flags = {CfileFlag.Cached}
addFileToCompile(m.config, cf)
close(m.ndi)
onExit()
proc updateCachedModule(m: BModule) =
let cfile = getCFile(m)