Commit ee9a8742 authored by Andrew Xu's avatar Andrew Xu Committed by Commit Bot

[Multipaste] Destruct the menu after menu gets closed

This CL resets the unique pointer to the menu model adapter which runs
the multipaste menu. Note that the destruction is called asynchronously.
Because the callback of closing the menu is called from MenuRunnerImpl.
Meanwhile, MenuRunnerImpl lives in the menu model adapter. So it is
risky to destruct the menu model adapter in a synchronous way, although
it works fine right now.

Bug: 1148591
Change-Id: Ifdd2d526d74b60090eb495cdc3c0309d475e4f66
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2536850Reviewed-by: default avatarDavid Black <dmblack@google.com>
Commit-Queue: Andrew Xu <andrewxu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827138}
parent 109cbbf8
......@@ -438,6 +438,17 @@ gfx::Rect ClipboardHistoryControllerImpl::CalculateAnchorRect() const {
void ClipboardHistoryControllerImpl::OnMenuClosed() {
accelerator_target_->OnMenuClosed();
// Reset `context_menu_` in the asynchronous way. Because the menu may be
// accessed after `OnMenuClosed()` is called.
base::SequencedTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(
[](const base::WeakPtr<ClipboardHistoryControllerImpl>&
controller_weak_ptr) {
if (controller_weak_ptr)
controller_weak_ptr->context_menu_.reset();
},
weak_ptr_factory_.GetWeakPtr()));
}
} // namespace ash
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