Fix page being removed too early. Fixes #3986 (intermittent failure).

This commit is contained in:
Glenn Watson 2015-02-06 14:59:42 +10:00
parent 237cdee9e4
commit 5ef9eaa1e1
2 changed files with 6 additions and 4 deletions

View file

@ -752,9 +752,10 @@ impl ScriptTask {
}
// otherwise find just the matching page and exit all sub-pages
match page.remove(id) {
match page.find(id) {
Some(ref mut page) => {
shut_down_layout(&*page, (*self.js_runtime).ptr, exit_type);
page.remove(id);
false
}
// TODO(tkuehn): pipeline closing is currently duplicated across
@ -1309,8 +1310,9 @@ fn shut_down_layout(page_tree: &Rc<Page>, rt: *mut JSRuntime, exit_type: Pipelin
// processed this message.
let (response_chan, response_port) = channel();
let LayoutChan(ref chan) = page.layout_chan;
chan.send(layout_interface::Msg::PrepareToExit(response_chan)).unwrap();
response_port.recv().unwrap();
if chan.send(layout_interface::Msg::PrepareToExit(response_chan)).is_ok() {
response_port.recv().unwrap();
}
}
// Remove our references to the DOM objects in this page tree.
@ -1332,7 +1334,7 @@ fn shut_down_layout(page_tree: &Rc<Page>, rt: *mut JSRuntime, exit_type: Pipelin
// Destroy the layout task. If there were node leaks, layout will now crash safely.
for page in page_tree.iter() {
let LayoutChan(ref chan) = page.layout_chan;
chan.send(layout_interface::Msg::ExitNow(exit_type)).unwrap();
chan.send(layout_interface::Msg::ExitNow(exit_type)).ok();
}
}