summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-04 22:32:41 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-04 22:32:41 +0000
commite432d4cbdf610a02ed7aea0bf181e4a47df5dad7 (patch)
treec35b4e8314f53ef940a522119899a98b94499f40 /views
parentb53ca567382de02e7a7d511cc03324bef39cb4c9 (diff)
downloadchromium_src-e432d4cbdf610a02ed7aea0bf181e4a47df5dad7.zip
chromium_src-e432d4cbdf610a02ed7aea0bf181e4a47df5dad7.tar.gz
chromium_src-e432d4cbdf610a02ed7aea0bf181e4a47df5dad7.tar.bz2
Fixes bug in removing nodes from tree. Specifically if the root is not
shown and you remove a node that is a child of the root, we silently fail as there is no tree item for the root. Not having a tree item for a node is typically fine (it usually means it hasn't been expanded), but in this case it's wrong. We need to special case removing from the root here. BUG=26606 TEST=see bug, but also make sure no regression in removing nodes from bookmark manager's tree. Review URL: http://codereview.chromium.org/360021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31022 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/controls/tree/tree_view.cc18
1 files changed, 14 insertions, 4 deletions
diff --git a/views/controls/tree/tree_view.cc b/views/controls/tree/tree_view.cc
index db2c315..5d39241 100644
--- a/views/controls/tree/tree_view.cc
+++ b/views/controls/tree/tree_view.cc
@@ -242,16 +242,26 @@ void TreeView::TreeNodesRemoved(TreeModel* model,
int start,
int count) {
DCHECK(parent && start >= 0 && count > 0);
- HTREEITEM parent_tree_item = GetTreeItemForNodeDuringMutation(parent);
- if (!parent_tree_item)
- return;
+
+ HTREEITEM tree_item;
+ if (!root_shown_ && parent == model->GetRoot()) {
+ // NOTE: we can't call GetTreeItemForNodeDuringMutation here as in this
+ // configuration the root has no treeitem.
+ tree_item = TreeView_GetRoot(tree_view_);
+ } else {
+ HTREEITEM parent_tree_item = GetTreeItemForNodeDuringMutation(parent);
+ if (!parent_tree_item)
+ return;
+
+ tree_item = TreeView_GetChild(tree_view_, parent_tree_item);
+ }
// Find the last item. Windows doesn't offer a convenient way to get the
// TREEITEM at a particular index, so we iterate.
- HTREEITEM tree_item = TreeView_GetChild(tree_view_, parent_tree_item);
for (int i = 0; i < (start + count - 1); ++i) {
tree_item = TreeView_GetNextSibling(tree_view_, tree_item);
}
+
// NOTE: the direction doesn't matter here. I've made it backwards to
// reinforce we're deleting from the end forward.
for (int i = count - 1; i >= 0; --i) {