Partially fix a memory leak
This commit is contained in:
1 parent
d40a12d1f1
commit
7dd5561faa
3 files changed
+13
-3
No files matched your search
@@ -14,7 +14,7 @@ function CreateAsyncTask(taskFunc as object, input as object, callback = invalid
|
||||
|
||||
m[`asynctask_${id}`] = task
|
||||
m[`asynctask_${id}_callback`] = callback
|
||||
task.ObserveField("state", FuncName(OnTaskState))
|
||||
task.ObserveFieldScoped("state", FuncName(OnTaskState))
|
||||
|
||||
return task
|
||||
end function
|
||||
@@ -36,6 +36,8 @@ function OnTaskState(e as object) as void
|
||||
return
|
||||
end if
|
||||
|
||||
task.UnobserveFieldScoped("state")
|
||||
|
||||
id = task.id
|
||||
output = task.output
|
||||
' if output is invalid, it means the task was interrupted before the result is ready
|
||||
@@ -46,6 +48,9 @@ function OnTaskState(e as object) as void
|
||||
end if
|
||||
end if
|
||||
|
||||
|
||||
task.input = invalid
|
||||
task.output = invalid
|
||||
m.delete(`asynctask_${id}`)
|
||||
m.delete(`asynctask_${id}_callback`)
|
||||
end function
|
||||
Reference in new issue
Block a user