From b262fc16e0eed30347df2590c14e7ebc74de2bb4 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 4 Feb 2015 00:04:12 +0800 Subject: [PATCH] Modified constellation key event handler to deal with missing frames --- components/compositing/constellation.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs index 45324165d0d..c59184f8631 100644 --- a/components/compositing/constellation.rs +++ b/components/compositing/constellation.rs @@ -885,11 +885,17 @@ impl Constellation { } fn handle_key_msg(&self, key: Key, state: KeyState, mods: KeyModifiers) { - self.current_frame().as_ref().map(|frame| { - let ScriptControlChan(ref chan) = frame.pipeline.borrow().script_chan; - chan.send(ConstellationControlMsg::SendEvent( - frame.pipeline.borrow().id, CompositorEvent::KeyEvent(key, state, mods))).unwrap(); - }); + match *self.current_frame() { + Some(ref frame) => { + let ScriptControlChan(ref chan) = frame.pipeline.borrow().script_chan; + chan.send(ConstellationControlMsg::SendEvent( + frame.pipeline.borrow().id, + CompositorEvent::KeyEvent(key, state, mods))).unwrap(); + }, + None => self.compositor_proxy.clone_compositor_proxy() + .send(CompositorMsg::KeyEvent(key, mods)) + } + } fn handle_get_pipeline_title_msg(&mut self, pipeline_id: PipelineId) {