diff options
Diffstat (limited to 'components/script/dom/gamepad.rs')
-rw-r--r-- | components/script/dom/gamepad.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/components/script/dom/gamepad.rs b/components/script/dom/gamepad.rs index cb0c20ac50e..a7f65050941 100644 --- a/components/script/dom/gamepad.rs +++ b/components/script/dom/gamepad.rs @@ -20,6 +20,7 @@ use dom_struct::dom_struct; use js::jsapi::{Heap, JSContext, JSObject}; use js::typedarray::{Float64Array, CreateWith}; use std::cell::Cell; +use std::ptr; use webvr_traits::{WebVRGamepadData, WebVRGamepadHand, WebVRGamepadState}; #[dom_struct] @@ -86,9 +87,13 @@ impl Gamepad { data.display_id), global, GamepadBinding::Wrap); + + let cx = global.get_cx(); + rooted!(in (cx) let mut array = ptr::null_mut()); unsafe { - let _ = Float64Array::create(global.get_cx(), CreateWith::Slice(&state.axes), gamepad.axes.handle_mut()); + let _ = Float64Array::create(cx, CreateWith::Slice(&state.axes), array.handle_mut()); } + gamepad.axes.set(array.get()); gamepad } |