From 70eccee7bcdc5486cfb339c95f8995970a2f41d1 Mon Sep 17 00:00:00 2001 From: bptato Date: Sun, 2 Jul 2023 10:54:22 +0200 Subject: Add finalizer to WebFile This is required because finalizers are not inherited. --- src/types/blob.nim | 6 ++++++ 1 file changed, 6 insertions(+) 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 -- cgit 1.4.1-2-gfad0