From 36fbbea2b558c6646d58d217c9103a320d451fc7 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Fri, 3 Jul 2020 03:33:59 +0200 Subject: Return Option for Window's layout channel --- components/script/script_thread.rs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'components/script/script_thread.rs') diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 0ef48e78b17..067fce6b08e 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -1172,9 +1172,13 @@ impl ScriptThread { ); }, }; - let _ = window - .layout_chan() - .send(Msg::RegisterPaint(name, properties, painter)); + + match window.layout_chan() { + Some(chan) => chan + .send(Msg::RegisterPaint(name, properties, painter)) + .unwrap(), + None => warn!("Layout channel unavailable"), + } } pub fn push_new_element_queue() { @@ -2467,12 +2471,12 @@ impl ScriptThread { }); // Pick a layout thread, any layout thread - let current_layout_chan = self + let current_layout_chan: Option> = self .documents .borrow() .iter() .next() - .map(|(_, document)| document.window().layout_chan().clone()) + .and_then(|(_, document)| document.window().layout_chan().cloned()) .or_else(|| { self.incomplete_loads .borrow() @@ -2879,7 +2883,10 @@ impl ScriptThread { let load = self.incomplete_loads.borrow_mut().remove(idx); load.layout_chan.clone() } else if let Some(ref document) = document { - document.window().layout_chan().clone() + match document.window().layout_chan() { + Some(chan) => chan.clone(), + None => return warn!("Layout channel unavailable"), + } } else { return warn!("Exiting nonexistant pipeline {}.", id); }; -- cgit v1.2.3