diff options
author | bptato <nincsnevem662@gmail.com> | 2023-07-02 10:54:22 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-07-02 10:54:22 +0200 |
commit | 70eccee7bcdc5486cfb339c95f8995970a2f41d1 (patch) | |
tree | 8d4edf5111a3e46f2f796ea4a8bf18903d8e5457 | |
parent | 78d97134d05e07d8b08735643f53a172d3108fa8 (diff) | |
download | chawan-70eccee7bcdc5486cfb339c95f8995970a2f41d1.tar.gz |
Add finalizer to WebFile
This is required because finalizers are not inherited.
-rw-r--r-- | src/types/blob.nim | 6 |
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 |