Bug 31314 - [Viewers] ElementComparer and Viewers
Summary: [Viewers] ElementComparer and Viewers
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1 RC1   Edit
Assignee: Nick Edgar CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-02-07 10:57 EST by Dirk Baeumer CLA
Modified: 2003-02-13 11:02 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Baeumer CLA 2003-02-07 10:57:37 EST
I20030206

We are seeing problems where we get staled working copies in selection change 
event sent out by a structured viewer. We don't have a reproducable case yet,
but it seems to be related to the following situation:

- the JavaElementComparer maps working copy elements and original elements.
  So wc.euals(original) == true.

- since working copies can get staled the viewer must ensure that whenever 
  items in the viewer get updated or refresh the viewer always uses the new
  element in the item's data pointer or in the hash table, even if 
  new.equals(old), since old can get staled.

Nick, can you think about cases in the structured viewer where old elements get 
kept ?
Comment 1 Dirk Baeumer CLA 2003-02-07 12:02:08 EST
We found a case where calling refresb(element, false) caused a situation that 
the old element was kept. We fixed it on your side my implementing the comparer 
in a way that a stale working copy element != original element.

But neverless the viewer would be "more stable" if it always keeps references 
to the last updated elements.

The corresponding viewer code is (TableViewer.internalRefresh(...):

// if the element is unchanged, update its label if appropriate
if (equals(children[i], items[i].getData())) {
	if (updateLabels) {
	    updateItem(items[i], children[i]);
	}
}

if the elements are equals and and no label update, then the item keeps 
the "old" element, even if getChildren provided "new" elements.
Comment 2 Dirk Baeumer CLA 2003-02-12 05:35:47 EST
We had to remove the JavaElementComparer from all views except the package 
explorer. The reason is that the fix we put into the comparer regarding stale 
working copies led to garbage in th hash table. The scenario is as follows:

- CU switches to working copy. The elements are equals hence the map element->
  item changes. Key is now working copy
- WC switches to CU. When we receive the delta the WC is already stale 
  resulting in the situation that the map entry for the WC didn't get removed
  since WC != CU in this case.

So conisdering the case that updateLabel is false as desribed in comment #1 is 
necessary.
Comment 3 Nick Edgar CLA 2003-02-13 11:02:23 EST
Fixed TableViewer.internalRefresh.  AbstractTreeViewer should already handle 
this properly.  Please let me know if you see this again.
In I20030213.