diff options
author | Pawel Piech | 2008-11-21 23:02:09 +0000 |
---|---|---|
committer | Pawel Piech | 2008-11-21 23:02:09 +0000 |
commit | 36bdae3933c8113aa01b0fa9df50f9b79ff76790 (patch) | |
tree | 595f86c9e1057ce9fa6bc5f9332e38c006b28dea /org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java | |
parent | acc1bf406874332479632cbda22eb6d740a875d9 (diff) | |
download | eclipse.platform.debug-36bdae3933c8113aa01b0fa9df50f9b79ff76790.tar.gz eclipse.platform.debug-36bdae3933c8113aa01b0fa9df50f9b79ff76790.tar.xz eclipse.platform.debug-36bdae3933c8113aa01b0fa9df50f9b79ff76790.zip |
Bug 256181 - [Flex-Hierarchy] State restore logic can get into a cycle.
Diffstat (limited to 'org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java')
-rw-r--r-- | org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java index e54077f5f..30b010fdd 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java @@ -596,26 +596,40 @@ public class TreeModelContentProvider extends ModelContentProvider implements IL } if (setTopItem) { - TreePath itemPath = getViewerTreePath(delta); - Widget topItem = viewer.findItem(itemPath); + Widget topItem = viewer.findItem(treePath); if (topItem instanceof TreeItem) { viewer.getTree().setTopItem((TreeItem) topItem); } } } - // If we know the children, look for the reveal delta in - // the child deltas. For the children with reveal - // flag start a new update. + // If we know the child count of the element, look for the reveal + // flag in the child deltas. For the children with reveal flag start + // a new update. + // If the child delta's index is out of range, strip the reveal flag + // since it is no longer applicable. if (knowsChildCount) { - IModelDelta[] childDeltas = delta.getChildDeltas(); - for (int i = 0; i < childDeltas.length; i++) { - IModelDelta childDelta = childDeltas[i]; - int modelIndex = childDelta.getIndex(); - if (modelIndex >= 0 && (childDelta.getFlags() & IModelDelta.REVEAL) != 0) { - doUpdateElement(treePath, modelIndex); - } - } + Widget item = viewer.findItem(treePath); + int childCount = -1; + if (item instanceof TreeItem) { + childCount = ((TreeItem)item).getItemCount(); + } else if (item instanceof Tree) { + childCount = ((Tree)item).getItemCount(); + } + if (childCount >= 0) { + ModelDelta[] childDeltas = (ModelDelta[])delta.getChildDeltas(); + for (int i = 0; i < childDeltas.length; i++) { + ModelDelta childDelta = childDeltas[i]; + int modelIndex = childDelta.getIndex(); + if (modelIndex >= 0 && (childDelta.getFlags() & IModelDelta.REVEAL) != 0) { + if (modelIndex < childCount) { + doUpdateElement(treePath, modelIndex); + } else { + childDelta.setFlags(childDelta.getFlags() & ~IModelDelta.REVEAL); + } + } + } + } } checkIfRestoreComplete(); |