Skip to content

Commit

Permalink
saved_desks: Fix crash in DeskMiniView when saving desk
Browse files Browse the repository at this point in the history
DeskMiniView's constructor installs a focus predicate that may be called
after the desk that the mini view refers to has been destroyed. The
predicate was assuming that `desk_` is not null, but this doesn't always
hold. The mini view already tracks the deletion of its desk and sets
`desk_` to null when this happens, so we can simply check in the
predicate.

BUG=b:263159388

Change-Id: I21f3db7bb4c2902c469a5ad776167c82fe8d9a4e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4116053
Commit-Queue: Daniel Andersson <dandersson@chromium.org>
Reviewed-by: Yongshun Liu <yongshun@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1085187}
  • Loading branch information
Daniel Andersson authored and Chromium LUCI CQ committed Dec 19, 2022
1 parent ac060b9 commit 3b11b90
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ash/wm/desks/desk_mini_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ DeskMiniView::DeskMiniView(DesksBarView* owner_bar,
IsPointOnMiniView(
owner_bar_->last_dragged_item_screen_location())) ||
desk_preview_->IsViewHighlighted() ||
(desk_->is_active() &&
(desk_ && desk_->is_active() &&
!owner_bar_->overview_grid()->IsShowingSavedDeskLibrary());
});

Expand Down
5 changes: 2 additions & 3 deletions ash/wm/desks/desk_mini_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,8 @@ class ASH_EXPORT DeskMiniView : public views::View,
// The root window on which this mini_view is created.
aura::Window* const root_window_;

// The associated desk. Can be null when the desk is deleted before this
// mini_view completes its removal animation. See comment above
// OnDeskRemoved().
// The associated desk. This can become null if the desk is deleted before the
// mini view is done. Desk deletion is monitored by `OnDeskDestroyed`.
Desk* desk_; // Not owned.

// The view that shows a preview of the desk contents.
Expand Down

0 comments on commit 3b11b90

Please sign in to comment.