aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBobby Holley <bobbyholley@gmail.com>2015-10-20 15:40:47 -0700
committerBobby Holley <bobbyholley@gmail.com>2015-10-27 12:41:14 -0700
commit85596b55106775d1eef948c39708c1b02499a9a4 (patch)
treef18b4ce1489bf306b8fc10e700aa45c55d662808
parent630b9f8fa0b953838b1778a3eca331c7e970cbc9 (diff)
downloadservo-85596b55106775d1eef948c39708c1b02499a9a4.tar.gz
servo-85596b55106775d1eef948c39708c1b02499a9a4.zip
Use an RAII guard to join the script task.
-rw-r--r--components/layout/layout_task.rs16
1 files changed, 12 insertions, 4 deletions
diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs
index 9c3a3e7ea4c..f3fd3546671 100644
--- a/components/layout/layout_task.rs
+++ b/components/layout/layout_task.rs
@@ -67,7 +67,7 @@ use std::cell::Cell;
use std::collections::HashMap;
use std::collections::hash_state::DefaultState;
use std::mem::transmute;
-use std::ops::{Deref, DerefMut};
+use std::ops::{Deref, DerefMut, Drop};
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::mpsc::{channel, Sender, Receiver};
use std::sync::{Arc, Mutex, MutexGuard};
@@ -1125,6 +1125,17 @@ impl LayoutTask {
fn handle_reflow<'a>(&'a self,
data: &ScriptReflow,
possibly_locked_rw_data: &mut Option<MutexGuard<'a, LayoutTaskData>>) {
+
+ // Make sure that every return path from this method joins the script task,
+ // otherwise the script task will panic.
+ struct AutoJoinScriptTask<'a> { data: &'a ScriptReflow };
+ impl<'a> Drop for AutoJoinScriptTask<'a> {
+ fn drop(&mut self) {
+ self.data.script_join_chan.send(()).unwrap();
+ }
+ };
+ let _ajst = AutoJoinScriptTask { data: data };
+
// FIXME: Isolate this transmutation into a "bridge" module.
// FIXME(rust#16366): The following line had to be moved because of a
// rustc bug. It should be in the next unsafe block.
@@ -1245,9 +1256,6 @@ impl LayoutTask {
ReflowQueryType::NoQuery => {}
}
}
-
- // Tell script that we're done.
- data.script_join_chan.send(()).unwrap();
}
fn set_visible_rects<'a>(&'a self,