| Summary: | NPE in Control.invalidateVisibleRegion when expanding/collapsing tree node | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Nick Edgar <n.a.edgar> | ||||
| Component: | SWT | Assignee: | Silenio Quarti <Silenio_Quarti> | ||||
| Status: | RESOLVED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | gheorghe, Silenio_Quarti, skovatch | ||||
| Version: | 3.6 | Flags: | skovatch:
review+
gheorghe: review+ |
||||
| Target Milestone: | 3.6 RC2 | ||||||
| Hardware: | PC | ||||||
| OS: | Mac OS X - Carbon (unsup.) | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
|
Description
Nick Edgar
Do I need RTC to reproduce this or will a straight 3.6 work? This testcase reproduces the problem. The editor is disposed when it looses focus after calling NSView.setHidden().
import org.eclipse.swt.custom.TreeEditor;
import org.eclipse.swt.events.*;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.*;
public class PR313424 {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new GridLayout(1, false));
final Tree tree = new Tree(shell, SWT.BORDER);
for (int i = 0; i < 3; i++) {
TreeItem item = new TreeItem(tree, SWT.NONE);
item.setText("item " + i);
for (int j = 0; j < 3; j++) {
TreeItem subItem = new TreeItem(item, SWT.NONE);
subItem.setText("item " + i + " " + j);
}
}
final TreeEditor editor = new TreeEditor(tree);
//The editor must have the same size as the cell and must
//not be any smaller than 50 pixels.
editor.horizontalAlignment = SWT.LEFT;
editor.grabHorizontal = true;
editor.minimumWidth = 50;
tree.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
// Clean up any previous editor control
Control oldEditor = editor.getEditor();
if (oldEditor != null) oldEditor.dispose();
// Identify the selected row
TreeItem item = (TreeItem)e.item;
if (item == null) return;
// The control that will be the editor must be a child of the Tree
final Text newEditor = new Text(tree, SWT.NONE);
newEditor.setText(item.getText());
newEditor.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
Text text = (Text)editor.getEditor();
editor.getItem().setText(text.getText());
}
});
newEditor.addListener(SWT.FocusOut, new Listener() {
public void handleEvent(Event event) {
newEditor.dispose();
}
});
newEditor.selectAll();
newEditor.setFocus();
editor.setEditor(newEditor, item);
}
});
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
Created attachment 169030 [details]
fix
Fixed > 20100518 (build I20100519-0839 should have it) |