mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 14:21:16 +00:00
Fix single shot timer leaks in the nodejs api
As discussed, don't use the persistent context approach for single shot timers but store the callback directly in the global object and "delete" it afterwards.
This commit is contained in:
parent
b42c16851a
commit
0e04149868
3 changed files with 25 additions and 20 deletions
|
@ -40,16 +40,4 @@ impl<'a> PersistentContext<'a> {
|
|||
pub fn from_object(cx: &mut impl Context<'a>, o: Handle<'a, JsObject>) -> NeonResult<Self> {
|
||||
Ok(PersistentContext(o.get(cx, KEY)?.downcast_or_throw(cx)?))
|
||||
}
|
||||
|
||||
pub fn global(cx: &mut impl Context<'a>) -> NeonResult<Self> {
|
||||
let global_object: Handle<JsObject> = cx.global().downcast().unwrap();
|
||||
Ok(match global_object.get(cx, KEY)?.downcast() {
|
||||
Ok(array) => PersistentContext(array),
|
||||
Err(_) => {
|
||||
let ctx = PersistentContext::new(cx);
|
||||
ctx.save_to_object(cx, global_object);
|
||||
ctx
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue