diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-25 01:34:28 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-25 01:34:28 +0000 |
commit | eaa4f93a42eebdb24e42b762b1267069e02f80fd (patch) | |
tree | 77a614977e82f252a51977fde54c5d1de8e822c7 /views/controls | |
parent | 62bb18dc11e536437972f24b6ecd6c9e33c3f88c (diff) | |
download | chromium_src-eaa4f93a42eebdb24e42b762b1267069e02f80fd.zip chromium_src-eaa4f93a42eebdb24e42b762b1267069e02f80fd.tar.gz chromium_src-eaa4f93a42eebdb24e42b762b1267069e02f80fd.tar.bz2 |
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
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33023 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls')
-rw-r--r-- | views/controls/tree/tree_view.cc | 13 |
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; |