Community
Participate
Working Groups
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 (); }
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);
Fixed in version >v2114