Bug 98147 - Variables View does not show all children if same instance is expanded twice
Summary: Variables View does not show all children if same instance is expanded twice
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 critical (vote)
Target Milestone: 3.1.1   Edit
Assignee: Kevin Barnes CLA Friend
QA Contact:
URL:
Whiteboard:
Keywords:
: 58768 99614 100720 100881 101565 104982 106082 108976 109995 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-06-02 13:09 EDT by Markus Keller CLA Friend
Modified: 2005-09-21 03:51 EDT (History)
10 users (show)

See Also:


Attachments
RemoteTreeViewer patch (11.53 KB, patch)
2005-07-06 16:27 EDT, Kevin Barnes CLA Friend
no flags Details | Diff
cleaned up patch (11.49 KB, patch)
2005-07-07 11:51 EDT, Kevin Barnes CLA Friend
no flags Details | Diff
example problem (10.10 KB, image/png)
2005-07-26 12:14 EDT, Darin Wright CLA Friend
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA Friend 2005-06-02 13:09:05 EDT
N20050602-0010

- Debug the class below with the breakpoint where indicated.
- Expand t1 in the Variables view -> expands fine and shows fID and fName.
- Expand t2 -> only child fID is shown

package xy;
public class Try {
	String fName;
	int fID;
	
	public Try(String name, int id) {
		fName= name;
		fID= id;
	}
	
	public static void main(String[] args) {
		Try t= new Try("Hello", 5);
		callee(t, t);
	}
	
	static void callee(Try t1, Try t2) {
		boolean same= t1.equals(t2); //breakpoint here
	}
	
}
Comment 1 Darin Wright CLA Friend 2005-06-02 14:00:58 EDT
It's due to a problem in AbstractTreeViewer - which assumes an elemnet can 
only exist once in the tree: createAddedElements(...)/itemExists
(items,element).

The tree thinks the variable "fName" already exists (because it checks the 
cache of elements in the cached map), and just ends up refreshing the existing 
node in the tree, rather than adding a new one.
Comment 2 Darin Wright CLA Friend 2005-06-02 16:51:30 EDT
I thought a similar problem might occurr in the package explorer when showing 
overlapping working sets. However, the code path is different. The package 
explorer works in the main thread when a node is expanded, which assumes the 
children cannot be present yet. The variables view works in the background and 
performs "adds", which results in this problem.
Comment 3 Markus Keller CLA Friend 2005-06-03 04:50:26 EDT
Note that the PackageExplorer uses a tweaked TreeViewer to allow showing the
same element twice.

The example from comment 0 worked fine in M6 - something must have changed
between M6 and M7 that influences duplicate element handling.
Comment 4 Darin Wright CLA Friend 2005-06-03 09:30:46 EDT
It appears the fix to bug 92835 has broken the variables view. The private 
method itemExists(Item[] items, Object element) cannot be overriden. I will 
have to see if we should not be using an element map.
Comment 5 Tod Creasey CLA Friend 2005-06-03 09:45:18 EDT
Correct - the issue is with using a hashmap for lookup which assumes no
duplication. You will have this issue with any TreeViewer until there is true
support for duplicates
Comment 6 Darin Wright CLA Friend 2005-06-03 14:24:47 EDT
Changing to not use hashlookup, labels don't update properly. Only the labels 
for the first elements appear. Labels for the dups remain as "..." as the 
background label update finds/updates the first occurrence.
Comment 7 Tod Creasey CLA Friend 2005-06-03 14:44:15 EDT
Truth is that TreeViewers don't support multiple matches - I think any change we
make or any new code path you use could get you into this trouble (as you just saw).

You could copy internalAdd down to try and work around this - I really don't
want to make itemExists[] API as it is not meant to be and it would be hack to
get around the use of the tree viewer in an unsupported way.
Comment 8 Darin Wright CLA Friend 2005-06-13 09:03:43 EDT
*** Bug 99614 has been marked as a duplicate of this bug. ***
Comment 9 Darin Wright CLA Friend 2005-06-14 16:12:32 EDT
Deferred for post 3.1.

Too late for changes in 3.1, need to re-examine trees with duplicate elements 
post 3.1. 
Comment 10 Darin Wright CLA Friend 2005-06-20 12:47:08 EDT
*** Bug 100881 has been marked as a duplicate of this bug. ***
Comment 11 Darin Wright CLA Friend 2005-06-23 13:41:45 EDT
*** Bug 100720 has been marked as a duplicate of this bug. ***
Comment 12 Darin Wright CLA Friend 2005-06-23 22:26:46 EDT
*** Bug 101565 has been marked as a duplicate of this bug. ***
Comment 13 d CLA Friend 2005-06-24 01:14:28 EDT
Isn't this bad enough to delay 3.1?

That is, I have hard time believing that users would knowingly accept a debugger 
with this bug.

Btw do you know how annoying it is to hunt through all of the variables in the
view trying to find the one element that has the right ID _and_ is showing
all the fields?  Sure with this example and the one I provided the problem
is not too bad.  However try it when you have bunch of lists and trees to deal
with!  

Comment 14 Markus Keller CLA Friend 2005-06-24 04:34:07 EDT
As a workaround, you can call 'Run > Inspect' on the variable with incomplete
children.

When called on a selection in the variables view, the result (including
children) appears in the Expressions view. When called on a selection in the
editor, the result appears in a lightweight popup, which can quickly be
dismissed with the 'Esc' key.
Comment 15 Darin Wright CLA Friend 2005-06-24 09:13:40 EDT
This requires a non-trivial amount of work to fix, and was discovered too late 
to fix in 3.1. We will target 3.1.1.
Comment 16 Kevin Barnes CLA Friend 2005-07-06 16:27:40 EDT
Created attachment 24399 [details]
RemoteTreeViewer patch

added code to override default behavior where findItem(..) is called.
Substituted with a new findItems(..) method, then iterated through the returned
items. 
Patch appears to solve the problem. Will run with the code for a little while
before releasing.
Comment 17 Darin Wright CLA Friend 2005-07-07 11:21:32 EDT
*** Bug 58768 has been marked as a duplicate of this bug. ***
Comment 18 Kevin Barnes CLA Friend 2005-07-07 11:51:24 EDT
Created attachment 24427 [details]
cleaned up patch
Comment 19 Kevin Barnes CLA Friend 2005-07-11 11:56:50 EDT
committed patch to R3_1_maintenance and HEAD.
Comment 20 Kevin Barnes CLA Friend 2005-07-11 11:57:30 EDT
Darin, please verify.
Comment 21 Darin Wright CLA Friend 2005-07-11 15:31:18 EDT
Verified in HEAD. Found a problem with restoration of recursive data 
structures (but confirmed the problem also occurrs in the 3.1 code base - will 
file a new bug for that).
Comment 22 Darin Wright CLA Friend 2005-07-11 15:34:00 EDT
Verified in 3.1 maintenance stream.
Comment 23 Darin Wright CLA Friend 2005-07-25 09:25:06 EDT
*** Bug 104982 has been marked as a duplicate of this bug. ***
Comment 24 Darin Wright CLA Friend 2005-07-26 12:09:53 EDT
Re-opening. The fix only works for the top level elements. However, the 
secondary elements do not work properly. In this test case (from original bug 
report), only the top level t1 and t2 show duplicate children, but the inst 
var fName does not show duplicate children properly.
Comment 25 Darin Wright CLA Friend 2005-07-26 12:14:42 EDT
Created attachment 25303 [details]
example problem

Problem does not appear to be consistent - sometimes it works, sometimes does
not. Screenshot shows problem.
Comment 26 Darin Wright CLA Friend 2005-07-26 12:22:20 EDT
Problem appears related to auto expansion (restoration of expansion state). 
When I manually expand, all works well.
Comment 27 Kevin Barnes CLA Friend 2005-07-26 12:26:49 EDT
I see the problem with manual expansion also. 
I also notice that changing the expansion of t1.fName manually sometimes affects
the expansion of t2.fName when it should have no impact.
Comment 28 Darin Wright CLA Friend 2005-07-26 12:58:59 EDT
Fixed. Problem was in replace(...) code in remote tree viewer. When replacing 
children for a parent, if the number of new children is > number of old 
children, we simply do an 'add(parent, children)' on the remaining children. 
However, this added to the other (duplicate) parent. Instead, an 'internalAdd
(...)' on the specific widget should be performed. The replace code already 
loops thru all parents, so children will be added to all parents.

Changes to RemoteTreeViewer.
Comment 29 Darin Wright CLA Friend 2005-07-26 13:00:58 EDT
Released fix to 3.1.1 and 3.2. Please verify, Kevin.
Comment 30 Kevin Barnes CLA Friend 2005-07-26 15:34:01 EDT
verified
Comment 31 Darin Wright CLA Friend 2005-08-04 15:56:29 EDT
*** Bug 106082 has been marked as a duplicate of this bug. ***
Comment 32 Darin Wright CLA Friend 2005-09-07 15:14:01 EDT
*** Bug 108976 has been marked as a duplicate of this bug. ***
Comment 33 Darin Wright CLA Friend 2005-09-20 09:26:44 EDT
*** Bug 109995 has been marked as a duplicate of this bug. ***