about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-07-02 10:54:22 +0200
committerbptato <nincsnevem662@gmail.com>2023-07-02 10:54:22 +0200
commit70eccee7bcdc5486cfb339c95f8995970a2f41d1 (patch)
tree8d4edf5111a3e46f2f796ea4a8bf18903d8e5457
parent78d97134d05e07d8b08735643f53a172d3108fa8 (diff)
downloadchawan-70eccee7bcdc5486cfb339c95f8995970a2f41d1.tar.gz
Add finalizer to WebFile
This is required because finalizers are not inherited.
-rw-r--r--src/types/blob.nim6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/types/blob.nim b/src/types/blob.nim
index 505e4f7c..3af362d4 100644
--- a/src/types/blob.nim
+++ b/src/types/blob.nim
@@ -34,6 +34,12 @@ proc newBlob*(buffer: pointer, size: int, ctype: string,
 proc finalize(blob: Blob) {.jsfin.} =
   if blob.deallocFun != nil and blob.buffer != nil:
     blob.deallocFun(blob.buffer)
+    blob.buffer = nil
+
+proc finalize(file: WebFile) {.jsfin.} =
+  if file.deallocFun != nil and file.buffer != nil:
+    file.deallocFun(file.buffer)
+    file.buffer = nil
 
 proc newWebFile*(path: string, webkitRelativePath = ""): WebFile =
   var file: File