Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Unified Diff: ui/message_center/views/message_list_view.cc

Issue 2913993002: Prevent crash on clear-all button in message center (Closed)
Patch Set: Revert back the unnecessary change Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/message_center/views/message_list_view.cc
diff --git a/ui/message_center/views/message_list_view.cc b/ui/message_center/views/message_list_view.cc
index 164dd00ec3b049a26e36b7d08626d9fa010cc72d..f98f3161880e5cd55de5dcd57ff44b9d15fafb3f 100644
--- a/ui/message_center/views/message_list_view.cc
+++ b/ui/message_center/views/message_list_view.cc
@@ -302,21 +302,35 @@ void MessageListView::OnBoundsAnimatorProgressed(
}
void MessageListView::OnBoundsAnimatorDone(views::BoundsAnimator* animator) {
- for (auto* view : deleted_when_done_)
- delete view;
- deleted_when_done_.clear();
+ bool need_update = false;
if (clear_all_started_) {
clear_all_started_ = false;
+ // TODO(yoshiki): we shouldn't touch views in OnAllNotificationsCleared().
+ // Or rename it to like OnAllNotificationsClearing().
for (auto& observer : observers_)
observer.OnAllNotificationsCleared();
+
+ if (!deleted_when_done_.empty())
Eliot Courtney 2017/06/01 07:53:16 Could you add a comment about why we need to call
yoshiki 2017/06/01 08:31:48 Done.
+ need_update = true;
}
+ // Ensures that the views are not destroyed yet.
Eliot Courtney 2017/06/01 07:53:16 Since this is a DCHECK, maybe "None of these views
yoshiki 2017/06/01 08:31:48 Done.
+ DCHECK(std::all_of(deleted_when_done_.begin(), deleted_when_done_.end(),
+ [this](views::View* view) { return Contains(view); }));
+
+ for (auto* view : deleted_when_done_)
+ delete view;
+ deleted_when_done_.clear();
+
if (has_deferred_task_) {
has_deferred_task_ = false;
- DoUpdateIfPossible();
+ need_update = true;
}
+ if (need_update)
+ DoUpdateIfPossible();
+
if (GetWidget())
GetWidget()->SynthesizeMouseMoveEvent();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698