Commit a75ce1b6 authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

overview: Cancel nudge if window destroyed.

Speculative fix for the linked bug. Was unable to repro manually, but
created a test case that is plausible that has a similar stack trace.

Test: TabletModeOverviewSessionTest.DestroyWindowDuringNudge
Bug: 997335
Change-Id: Ib580740b4c059aa30e44af57e895c27b610f1650
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2225587Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#775261}
parent 089264e2
......@@ -370,6 +370,8 @@ OverviewGrid::OverviewGrid(aura::Window* root_window,
OverviewGrid::~OverviewGrid() = default;
void OverviewGrid::Shutdown() {
EndNudge();
SplitViewController::Get(root_window_)->RemoveObserver(this);
ScreenRotationAnimator::GetForRootWindow(root_window_)->RemoveObserver(this);
Shell::Get()->wallpaper_controller()->RemoveObserver(this);
......@@ -591,6 +593,8 @@ void OverviewGrid::AddItemInMruOrder(aura::Window* window,
void OverviewGrid::RemoveItem(OverviewItem* overview_item,
bool item_destroying,
bool reposition) {
EndNudge();
// Use reverse iterator to be efficient when removing all.
auto iter = std::find_if(window_list_.rbegin(), window_list_.rend(),
base::MatchesUniquePtr(overview_item));
......
......@@ -3776,6 +3776,31 @@ TEST_P(TabletModeOverviewSessionTest, NoNudgingWhenLastItemOnPreviousRowDrops) {
EXPECT_EQ(item_bounds[4], items[4]->target_bounds());
}
// Tests that there is no crash when destroying a window during a nudge drag.
// Regression test for https://crbug.com/997335.
TEST_P(TabletModeOverviewSessionTest, DestroyWindowDuringNudge) {
std::unique_ptr<aura::Window> window1 = CreateTestWindow();
std::unique_ptr<aura::Window> window2 = CreateTestWindow();
std::unique_ptr<aura::Window> window3 = CreateTestWindow();
ToggleOverview();
ASSERT_TRUE(overview_controller()->InOverviewSession());
OverviewItem* item = GetOverviewItemForWindow(window1.get());
const gfx::PointF item_center = item->target_bounds().CenterPoint();
// Drag |item1| vertically to start nudging.
overview_session()->InitiateDrag(item, item_center,
/*is_touch_dragging=*/true);
overview_session()->Drag(item, item_center + gfx::Vector2dF(0, 160));
// Destroy |window2| and |window3|,then keep dragging. There should be no
// crash.
window2.reset();
window3.reset();
overview_session()->Drag(item, item_center + gfx::Vector2dF(0, 260));
}
TEST_P(TabletModeOverviewSessionTest, MultiTouch) {
const gfx::Rect bounds(400, 400);
std::unique_ptr<aura::Window> window1(CreateTestWindow(bounds));
......
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