Project: SWT
Bug 126299 After clearAll(), GTK virtual Tree forgets old TreeItem objects and creates new ones
Reported: 2006-02-02 21:24:45 | Status: resolved fixed

The attached snippet repeatedly calls clearAll() on the tree and prints out the length of the "items" array of the tree instance. Apparently, the existing TreeItem objects are forgotten and new ones are created after you call clearAll() and then cause the callback to happen. (Confirmed by putting a breakpoint in the constructor of TreeItem.) This is the main part of the snippet: for (int i = 0; i < 5; i++) { tree.clearAll(true); while (display.readAndDispatch()); System.out.println("items.length: " + ((Object[])field.get(tree)).length); } This is what it prints: items.length: 12 items.length: 20 items.length: 32 items.length: 40 items.length: 52 items.length: 60 I would expect the length of the array to remain constant, and that no TreeItem objects are created after you call clearAll().

Files changed in fix:
bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java