From 8d03afaa6214f583f526587f3865b4ccad45cad3 Mon Sep 17 00:00:00 2001 From: domlaskowski Date: Thu, 4 May 2017 17:27:02 -0700 Subject: [PATCH] exo: Fix multi-display cursor crash The cursor surface is parented to the primary root window, which may change when using multiple displays. This CL fixes a crash caused by removing the child from the primary root window when the parent is a different root window or the child is orphaned. BUG=714832 TEST=No crashes after changing primary display. Review-Url: https://codereview.chromium.org/2862953002 Cr-Commit-Position: refs/heads/master@{#469543} --- components/exo/pointer.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/components/exo/pointer.cc b/components/exo/pointer.cc index f81ebbe5f84c15..073c750192f374 100644 --- a/components/exo/pointer.cc +++ b/components/exo/pointer.cc @@ -89,9 +89,8 @@ void Pointer::SetCursor(Surface* surface, const gfx::Point& hotspot) { } if (surface_) { surface_->window()->SetTransform(gfx::Transform()); - WMHelper::GetInstance() - ->GetContainer(ash::kShellWindowId_MouseCursorContainer) - ->RemoveChild(surface_->window()); + if (surface_->window()->parent()) + surface_->window()->parent()->RemoveChild(surface_->window()); surface_->SetSurfaceDelegate(nullptr); surface_->RemoveSurfaceObserver(this); }