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

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

Issue 2913993002: Prevent crash on clear-all button in message center (Closed)
Patch Set: Addressed comments (updating comments) 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..127f3fdc8c4628542486fefdfff39ec06f359872 100644
--- a/ui/message_center/views/message_list_view.cc
+++ b/ui/message_center/views/message_list_view.cc
@@ -302,21 +302,36 @@ 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();
+
+ // Need to update layout after deleting the views.
+ if (!deleted_when_done_.empty())
+ need_update = true;
}
+ // None of these views should be deleted.
+ 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