Skip to content

Commit

Permalink
Fix Camera3D crash with preload
Browse files Browse the repository at this point in the history
When preloading, the initial Camera3D that was created does
not have an associated impl() (i.e. an input::Camera3D)
because an input manager is not instantiated in preload.

This change allows graceful transition from the placeholder
dom::Camera3D without input to a dom::Camera3D with input.

b/198526160

Change-Id: Ib65355a4205c971f37c5499b599dc877975acadc
(cherry picked from commit 9cb5d4454339405ff6beff41040479f087db0051)
  • Loading branch information
tphamg committed Sep 14, 2021
1 parent 5f8ad44 commit 2cc32ca
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cobalt/dom/window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -630,9 +630,11 @@ void Window::SetSize(ViewportSize size) {
}

void Window::UpdateCamera3D(const scoped_refptr<input::Camera3D>& camera_3d) {
if (camera_3d_) {
if (camera_3d_ && camera_3d_->impl()) {
// Update input object for existing camera.
camera_3d_->impl()->SetInput(camera_3d);
} else {
// Create a new camera which uses the given input camera object.
camera_3d_ = new Camera3D(camera_3d);
camera_3d_->StartOrientationEvents(base::AsWeakPtr(this));
}
Expand Down

0 comments on commit 2cc32ca

Please sign in to comment.