Commit 8a684dcb authored by robert.bradford's avatar robert.bradford Committed by Commit bot

Fix segfault when unplugging captured external display

When unplugging an external display the WindowTreeHost is destroyed, destroying
the window and stopping the capture. However the compositor is destroyed before
the window in the WindowTreeHost destructor.

This change add an extra check that the compositor is valid before dereferencing.

BUG=441747
TEST=on link_freon unplugging external display does not result in crash when
running desktopCapture example against the external display

Review URL: https://codereview.chromium.org/801823002

Cr-Commit-Position: refs/heads/master@{#308168}
parent c72391a1
......@@ -235,8 +235,10 @@ void DesktopVideoCaptureMachine::Stop(const base::Closure& callback) {
// Stop observing compositor and window events.
if (desktop_window_) {
if (desktop_window_->GetHost())
desktop_window_->GetHost()->compositor()->RemoveObserver(this);
aura::WindowTreeHost* window_host = desktop_window_->GetHost();
// In the host destructor the compositor is destroyed before the window.
if (window_host && window_host->compositor())
window_host->compositor()->RemoveObserver(this);
desktop_window_->RemoveObserver(this);
desktop_window_ = NULL;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment