Commit d17b4bcb authored by Mitsuru Oshima's avatar Mitsuru Oshima Committed by Commit Bot

Correctly track the target window's lifetime in WindowResizer

The recorder is created in constructor, so only scenario that I can
think of is that resizer is destroyed during SetBounds.

I also added CHECK to catch the scenario where the resizer is destroyed
during resize for other reasons. I'll remove the code once fix is confirmed.

Bug: 970911
Test: None. Repro step is unknown and this is speculative fix.
Change-Id: I58e20fe916664867b776d36b7720a2a2fb5ee357
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1655968Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#668458}
parent 30fdec4f
......@@ -85,7 +85,10 @@ WindowResizer::WindowResizer(wm::WindowState* window_state)
DCHECK(window_state_->drag_details());
}
WindowResizer::~WindowResizer() = default;
WindowResizer::~WindowResizer() {
if (destroyed_)
*destroyed_ = true;
}
// static
int WindowResizer::GetBoundsChangeForWindowComponent(int component) {
......@@ -269,14 +272,20 @@ bool WindowResizer::IsBottomEdge(int window_component) {
void WindowResizer::SetBoundsDuringResize(const gfx::Rect& bounds) {
aura::Window* window = GetTarget();
DCHECK(window);
const gfx::Rect original_bounds = window->bounds();
window->SetBounds(bounds);
bool destroyed = false;
destroyed_ = &destroyed;
aura::WindowTracker tracker;
tracker.Add(window);
const gfx::Rect original_bounds = window->bounds();
window->SetBounds(bounds);
if (tracker.windows().empty())
return; // Assume we've been destroyed.
if (bounds.size() == original_bounds.size())
return;
CHECK(!destroyed);
destroyed_ = nullptr;
recorder_->RequestNext();
}
......
......@@ -110,6 +110,8 @@ class ASH_EXPORT WindowResizer {
// Updates |new_bounds| to adhere to the aspect ratio.
void CalculateBoundsWithAspectRatio(float aspect_ratio,
gfx::Rect* new_bounds);
// Remove once it is confirmed that crbug.com/970911 is fixed.
bool* destroyed_ = nullptr;
std::unique_ptr<PresentationTimeRecorder> recorder_;
......
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