summaryrefslogtreecommitdiffstats
path: root/views/controls
diff options
context:
space:
mode:
authorian@chromium.org <ian@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-25 18:29:03 +0000
committerian@chromium.org <ian@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-25 18:29:03 +0000
commit479a5fc1a08b4e71712ab7045a3e30a18f884e00 (patch)
tree0855f81a087bf1b56612d6a1dba95a320fcc4d94 /views/controls
parent8ac2ba2d8d44566e14a6998a10b04df60a3f5fc8 (diff)
downloadchromium_src-479a5fc1a08b4e71712ab7045a3e30a18f884e00.zip
chromium_src-479a5fc1a08b4e71712ab7045a3e30a18f884e00.tar.gz
chromium_src-479a5fc1a08b4e71712ab7045a3e30a18f884e00.tar.bz2
Merge 33023 - This is required for merging 33069.
- Fixes two bugs in tree view: . Invoking SetRootShown before the tree was created resulted in updating internal structures with wrong info. This caused problems if you later tried to delete. I've added a DCHECK to make sure we don't hit this again. . Adding a node to the root when the root wasn't shown silently failed. BUG=none TEST=make sure bookmark manager doesn't have any problems when adding/removing nodes. Review URL: http://codereview.chromium.org/434053 TBR=sky@chromium.org Review URL: http://codereview.chromium.org/434085 git-svn-id: svn://svn.chromium.org/chrome/branches/249/src@33084 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls')
-rw-r--r--views/controls/tree/tree_view.cc13
1 files changed, 9 insertions, 4 deletions
diff --git a/views/controls/tree/tree_view.cc b/views/controls/tree/tree_view.cc
index 0c2a7c6..4b87cde 100644
--- a/views/controls/tree/tree_view.cc
+++ b/views/controls/tree/tree_view.cc
@@ -191,7 +191,7 @@ void TreeView::SetRootShown(bool root_shown) {
if (root_shown_ == root_shown)
return;
root_shown_ = root_shown;
- if (!model_)
+ if (!model_ || !tree_view_)
return;
// Repopulate the tree.
DeleteRootItems();
@@ -203,7 +203,8 @@ void TreeView::TreeNodesAdded(TreeModel* model,
int start,
int count) {
DCHECK(parent && start >= 0 && count > 0);
- if (node_to_details_map_.find(parent) == node_to_details_map_.end()) {
+ if (node_to_details_map_.find(parent) == node_to_details_map_.end() &&
+ (root_shown_ || parent != model_->GetRoot())) {
// User hasn't navigated to this entry yet. Ignore the change.
return;
}
@@ -235,8 +236,8 @@ void TreeView::TreeNodesAdded(TreeModel* model,
} else {
TreeModelNode* previous_sibling = model_->GetChild(parent, i + start - 1);
CreateItem(parent_tree_item,
- GetNodeDetails(previous_sibling)->tree_item,
- model_->GetChild(parent, i + start));
+ GetNodeDetails(previous_sibling)->tree_item,
+ model_->GetChild(parent, i + start));
}
}
}
@@ -557,6 +558,7 @@ void TreeView::DeleteRootItems() {
void TreeView::CreateRootItems() {
DCHECK(model_);
+ DCHECK(tree_view_);
TreeModelNode* root = model_->GetRoot();
if (root_shown_) {
CreateItem(NULL, TVI_LAST, root);
@@ -597,6 +599,9 @@ void TreeView::CreateItem(HTREEITEM parent_item,
// we set the map entries before adding the item.
NodeDetails* node_details = new NodeDetails(node_id, node);
+ DCHECK(node_to_details_map_.count(node) == 0);
+ DCHECK(id_to_details_map_.count(node_id) == 0);
+
node_to_details_map_[node] = node_details;
id_to_details_map_[node_id] = node_details;