Skip to content

Commit

Permalink
Drop TrustedPromise before dropping JSRuntime
Browse files Browse the repository at this point in the history
  • Loading branch information
CYBAI committed Oct 21, 2018
1 parent 2304f02 commit bca951d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions components/script/dom/bindings/refcounted.rs
Expand Up @@ -224,6 +224,12 @@ impl LiveDOMReferences {
});
}

pub fn destruct() {
LIVE_REFERENCES.with(|ref r| {
*r.borrow_mut() = None;
});
}

#[allow(unrooted_must_root)]
fn addref_promise(&self, promise: Rc<Promise>) {
let mut table = self.promise_table.borrow_mut();
Expand Down
5 changes: 4 additions & 1 deletion components/script/script_runtime.rs
Expand Up @@ -145,7 +145,10 @@ pub struct Runtime(RustRuntime);

impl Drop for Runtime {
fn drop(&mut self) {
THREAD_ACTIVE.with(|t| t.set(false));
THREAD_ACTIVE.with(|t| {
LiveDOMReferences::destruct();
t.set(false);
});
}
}

Expand Down

0 comments on commit bca951d

Please sign in to comment.