aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/window.rs
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2015-03-11 13:49:42 -0400
committerMs2ger <ms2ger@gmail.com>2015-03-23 19:19:18 +0100
commit48b151948f9eaa1ad732363bf46bb0c4b9719832 (patch)
treee882f7262dbfe614db4b1cb0dbd9b3a9e17247f2 /components/script/dom/window.rs
parentb1a35f549baad871a3691ae485af2efecd2d73f7 (diff)
downloadservo-48b151948f9eaa1ad732363bf46bb0c4b9719832.tar.gz
servo-48b151948f9eaa1ad732363bf46bb0c4b9719832.zip
Fix double-panic when the script task panics.
Diffstat (limited to 'components/script/dom/window.rs')
-rw-r--r--components/script/dom/window.rs17
1 files changed, 8 insertions, 9 deletions
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index 038ec358f73..88178374a45 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -155,6 +155,14 @@ pub struct Window {
}
impl Window {
+ #[allow(unsafe_code)]
+ pub fn clear_js_context_for_script_deallocation(&self) {
+ unsafe {
+ *self.js_context.borrow_for_script_deallocation() = None;
+ *self.browser_context.borrow_for_script_deallocation() = None;
+ }
+ }
+
pub fn get_cx(&self) -> *mut JSContext {
self.js_context.borrow().as_ref().unwrap().ptr
}
@@ -425,7 +433,6 @@ impl<'a> WindowMethods for JSRef<'a, Window> {
pub trait WindowHelpers {
fn clear_js_context(self);
- fn clear_js_context_for_script_deallocation(self);
fn init_browser_context(self, doc: JSRef<Document>, frame_element: Option<JSRef<Element>>);
fn load_url(self, href: DOMString);
fn handle_fire_timer(self, timer_id: TimerId);
@@ -499,14 +506,6 @@ impl<'a> WindowHelpers for JSRef<'a, Window> {
*self.browser_context.borrow_mut() = None;
}
- #[allow(unsafe_code)]
- fn clear_js_context_for_script_deallocation(self) {
- unsafe {
- *self.js_context.borrow_for_script_deallocation() = None;
- *self.browser_context.borrow_for_script_deallocation() = None;
- }
- }
-
/// Reflows the page if it's possible to do so and the page is dirty. This method will wait
/// for the layout thread to complete (but see the `TODO` below). If there is no window size
/// yet, the page is presumed invisible and no reflow is performed.