From bca951d79ed9d356c1a9f5a5f4d1ad5a943a3df2 Mon Sep 17 00:00:00 2001 From: CYBAI Date: Sun, 21 Oct 2018 21:30:19 +0800 Subject: [PATCH] Drop `TrustedPromise` before dropping JSRuntime --- components/script/dom/bindings/refcounted.rs | 6 ++++++ components/script/script_runtime.rs | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/components/script/dom/bindings/refcounted.rs b/components/script/dom/bindings/refcounted.rs index 11a422a2f3f..49add72e114 100644 --- a/components/script/dom/bindings/refcounted.rs +++ b/components/script/dom/bindings/refcounted.rs @@ -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) { let mut table = self.promise_table.borrow_mut(); diff --git a/components/script/script_runtime.rs b/components/script/script_runtime.rs index 18138dcc2b0..865382f091f 100644 --- a/components/script/script_runtime.rs +++ b/components/script/script_runtime.rs @@ -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); + }); } }