Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 388950

Summary: Virtual tree viewer contains wrong items after refresh
Product: [RT] RAP Reporter: Ken Wenzel <kenwenzel>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 Flags: ivan: review? (rsternberg)
Version: 2.0   
Target Milestone: 2.0 M2   
Hardware: All   
OS: All   
Whiteboard: sr151
Attachments:
Description Flags
Test case to reproduce this bug. none

Description Ken Wenzel CLA 2012-09-06 10:14:51 EDT
Created attachment 220787 [details]
Test case to reproduce this bug.

The virtual tree viewer contains wrong items if the underlying model is changed and treeViewer.refresh is called to synchronize the representation.

This bug is also described in the forum:
http://www.eclipse.org/forums/index.php/t/373464/
Comment 1 Ivan Furnadjiev CLA 2012-09-07 06:20:49 EDT
After some testing I found that the wrong text appears only if the item "2" is expanded before you click the "Test" button.
Comment 2 Ivan Furnadjiev CLA 2012-09-07 07:46:18 EDT
Test case that succeed in SWT but not in RAP:
public void testVirtualClearAll_DoesNotRequestData() {
    final List<Event> eventLog = new ArrayList<Event>();
    Tree tree = new Tree( shell, SWT.VIRTUAL );
    TreeItem parentItem = new TreeItem( tree, SWT.NONE );
    TreeItem item = new TreeItem( parentItem, SWT.NONE );
    item.setText( "item" ); // materialize the item
    tree.addListener( SWT.SetData, new Listener() {
      public void handleEvent( Event event ) {
        eventLog.add( event );
      }
    } );

    parentItem.clearAll( true );

    assertEquals( 0, eventLog.size() );
  }
TreeItem#clearAll should not re-materialize the item (request data).
Comment 3 Ivan Furnadjiev CLA 2012-09-07 08:05:54 EDT
The problem was in TreeItem#clearAll where the data are requested again (parent.checkData is called) for the cleared item. Fixed in master with commit 21bd6f5494697f48f827063147aeb623c93a36c5. I think we could backport this fix to 1.5 maintenance branch.
Comment 4 Ralf Sternberg CLA 2012-09-07 10:50:13 EDT
(In reply to comment #3)
> I think we could backport this fix to 1.5 maintenance branch.

+1
Comment 5 Ivan Furnadjiev CLA 2012-09-07 11:58:04 EDT
Backport the fix to 1.5 maintenance branch with commit c2009741bfdc2c220cc32ad56654eca3dc404683.