Bug 24273

Summary: GP -Tree removeAll reboot windowsXp
Product: [Eclipse Project] Platform Reporter: Felipe Heidrich <eclipse.felipe>
Component: SWTAssignee: Christophe Cornu <christophe.cornu+eclipse>
Status: RESOLVED FIXED QA Contact:
Severity: critical    
Priority: P1 Keywords: performance
Version: 2.0   
Target Milestone: 2.1 M4   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Felipe Heidrich CLA 2002-10-01 12:14:42 EDT
build 20020924
ensure you are using common-control 6.0


- Run the test case.
- Click in the test button, it will insert 350 items on Tree
- Click in the test button again, it will call removeAll for the Tree
- the removeall process is very slow, and eventually it will cause windows to 
reboot.


Testcase:
	public static void main (String [] args) {
		Display display = new Display ();
		Shell shell = new Shell (display);
		shell.setLayout(new FillLayout());
		
		final Tree tree = new Tree (shell, SWT.BORDER | 
SWT.FULL_SELECTION);
		Button button = new Button (shell, SWT.PUSH);
		button.setText("Test");
		button.addListener(SWT.Selection, new Listener() {
			public void handleEvent(Event event) {
				if (tree.getItemCount() == 0) {
					for (int i =0; i< 350; i++) {
						TreeItem item = new TreeItem 
(tree, 0);
						item.setText("Text " + i);
					}
				} else {
					tree.removeAll();
				}
			}
		});		
		
		shell.open ();
		while (!shell.isDisposed ()) {
			if (!display.readAndDispatch ())
				display.sleep ();
		}
		
		display.dispose ();
	}
Comment 1 Steve Northover CLA 2002-10-31 13:52:04 EST
Reproduced on 2 different XP boxes.
Manifest not required (thus it is not related to commctrl 6.0)
Only reproduced with the 'Window Classic' theme.

Note that tree.removeAll is unacceptably slow.
It is due to that line in Tree.removeAll:
int result = OS.SendMessage (handle, OS.TVM_DELETEITEM, 0, OS.TVI_ROOT);
The crash also occurs while the OS is processing this message.
Found reports that post commctr 4.72, this call can be slow unless redrawing is 
disabled.

Current workaround: disable redraw prior to removing all items
tree.setRedraw(false);
tree.removeAll();
tree.setRedraw(true);
Comment 2 Steve Northover CLA 2002-11-01 14:16:08 EST
Fixed in version >v2114