about summary refs log tree commit diff stats
path: root/src/display/client.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-06-27 18:39:04 +0200
committerbptato <nincsnevem662@gmail.com>2023-06-27 18:39:04 +0200
commit50eead4e8a483c06008553d803af8d1adaa0cc4f (patch)
treeaca92f016ef2b84461d6bd42591e5440bec5d028 /src/display/client.nim
parentcd1a36414028cbd3028a5f87ca9b91a314f5464c (diff)
downloadchawan-50eead4e8a483c06008553d803af8d1adaa0cc4f.tar.gz
Free JSRuntime, JSContext and ctors on exit
Diffstat (limited to 'src/display/client.nim')
-rw-r--r--src/display/client.nim9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/display/client.nim b/src/display/client.nim
index 49dae2ea..869435ce 100644
--- a/src/display/client.nim
+++ b/src/display/client.nim
@@ -59,7 +59,7 @@ type
     pager {.jsget.}: Pager
     line {.jsget.}: LineEdit
     config {.jsget.}: Config
-    store {.jsget, jsset.}: URL
+    store {.jsget, jsset.}: Document
     jsrt: JSRuntime
     jsctx: JSContext
     fdmap: Table[int, Container]
@@ -150,6 +150,13 @@ proc quit(client: Client, code = 0) {.jsfunc.} =
   if client.alive:
     client.alive = false
     client.pager.quit()
+    let ctx = client.jsctx
+    var global = JS_GetGlobalObject(ctx)
+    JS_FreeValue(ctx, global)
+    if client.jsctx != nil:
+      free(client.jsctx)
+    if client.jsrt != nil:
+      free(client.jsrt)
   quit(code)
 
 proc feedNext(client: Client) {.jsfunc.} =