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

Bug 320904

Summary: [Tree] Disposed treeitems still visible
Product: [RT] RAP Reporter: Benjamin Muskalla <b.muskalla>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: swimmer_86, tbuschto
Version: 1.4   
Target Milestone: 1.4 M1   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 320597    

Description Benjamin Muskalla CLA 2010-07-26 09:54:28 EDT
When disposing and creating new TreeItems, it may happen that the disposed TreeItems are still visible.

Snippet
-------------------

 Display display = new Display();
    Shell shell = new Shell( display );
    shell.setLayout( new GridLayout( 1, false ) );
    
    final Tree tree = new Tree( shell, SWT.SINGLE | SWT.FULL_SELECTION );
    tree.setLinesVisible( true );
    tree.setHeaderVisible( true );

    final TreeItem treeItem= new TreeItem(tree, SWT.NONE);
    treeItem.setText(0, "java.lang.Object");
    
    TreeItem treeItem2= new TreeItem(treeItem, SWT.NONE);
    treeItem2.setText(0, "byte[]");

    Button button = new Button( shell, SWT.PUSH );
    button.setLayoutData( new GridData( SWT.BEGINNING, SWT.CENTER, false, false ) );
    button.setText("replace contents");
    button.addSelectionListener( new SelectionAdapter() {
      public void widgetSelected( SelectionEvent e ) {
        tree.getItem( 0 ).dispose();
        
        TreeItem treeItem3= new TreeItem(tree, SWT.NONE);
        treeItem3.setText(0, "java.lang.Object");
        treeItem3.setExpanded( true );
        
        TreeItem treeItem4= new TreeItem(treeItem3, SWT.NONE);
        treeItem4.setText(0, "byte[]");
      }
    });
    
    shell.pack();
    shell.open();
    while( !shell.isDisposed() ) {
      if( !display.readAndDispatch() )
        display.sleep();
    }
    display.dispose();
    return 0;
Comment 1 Tim Buschtoens CLA 2010-07-26 10:03:17 EDT
Thanks Benny... (i guess...)
Comment 2 Tim Buschtoens CLA 2010-07-26 11:36:06 EDT
Fixed in CVS HEAD.
Comment 3 Yury CLA 2011-10-12 01:10:37 EDT
Hi, Tim.
Could you provide a patch here?

Yury.
Comment 4 Tim Buschtoens CLA 2011-10-12 05:06:42 EDT
Hi.

What version are you using exactly? This bug was fixed in 1.4M1, so you should be able to use 1.4.1 where its fixed.
Comment 5 Yury CLA 2011-10-12 06:42:55 EDT
We use RAP 1.4. I just want to know the cause of this bug, because it seems to me that it is sometimes reproduced in IE9, but I can not find clear steps to reproduce it. Therefore I hope that understanding the cause will help me to figure the problem out.

Yury.
Comment 6 Tim Buschtoens CLA 2011-10-12 07:23:59 EDT
The Tree has been changed so much since this was fixed, its unlikely the issues are related. If you want to see what was changed i suppose you would have to check out the 1.4 branch from cvs and look up the history of Tree.js and TreeItem.js. (Its Revision 1.5 and 1.2 respectively.)