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

Unified Diff: ui/app_list/app_list_model.cc

Issue 600393002: AppListModel / AppsGridView: Better error handling for corner cases. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@appsgridview-static-casts
Patch Set: Comment. Created 6 years, 3 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 | ui/app_list/app_list_model_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/app_list/app_list_model.cc
diff --git a/ui/app_list/app_list_model.cc b/ui/app_list/app_list_model.cc
index 22ac8a25634973496035b81e118e10ef1e14ad89..b3512c8b79f3e453c77d12aaa63224a6c1ccbf3f 100644
--- a/ui/app_list/app_list_model.cc
+++ b/ui/app_list/app_list_model.cc
@@ -91,13 +91,19 @@ const std::string AppListModel::MergeItems(const std::string& target_item_id,
return "";
}
DVLOG(2) << "MergeItems: " << source_item_id << " -> " << target_item_id;
+
+ if (target_item_id == source_item_id) {
+ LOG(WARNING) << "MergeItems tried to drop item onto itself ("
+ << source_item_id << " -> " << target_item_id << ").";
+ return "";
+ }
+
// Find the target item.
- AppListItem* target_item = FindItem(target_item_id);
+ AppListItem* target_item = top_level_item_list_->FindItem(target_item_id);
if (!target_item) {
LOG(ERROR) << "MergeItems: Target no longer exists.";
return "";
}
- CHECK(target_item->folder_id().empty());
AppListItem* source_item = FindItem(source_item_id);
if (!source_item) {
@@ -125,6 +131,8 @@ const std::string AppListModel::MergeItems(const std::string& target_item_id,
// location, they will become owned by the new folder.
scoped_ptr<AppListItem> source_item_ptr = RemoveItem(source_item);
CHECK(source_item_ptr);
+ // Note: This would fail if |target_item_id == source_item_id|, except we
+ // checked that they are distinct at the top of this method.
scoped_ptr<AppListItem> target_item_ptr =
top_level_item_list_->RemoveItem(target_item_id);
CHECK(target_item_ptr);
« no previous file with comments | « no previous file | ui/app_list/app_list_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698