| Summary: | [Widgets] NullPointerException at org.eclipse.swt.widgets.Link.textView_clickOnLink_atIndex | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Matt Barry <mrbcuda> | ||||
| Component: | SWT | Assignee: | Scott Kovatch <skovatch> | ||||
| Status: | RESOLVED FIXED | QA Contact: | Silenio Quarti <Silenio_Quarti> | ||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | andrew.eisenberg, lshanmug, pinnamur, Silenio_Quarti, vittorio | ||||
| Version: | 4.0 | ||||||
| Target Milestone: | 3.7 M2 | ||||||
| Hardware: | Macintosh | ||||||
| OS: | Mac OS X | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
|
Description
Matt Barry
Not sure how the offsets field is null. I guess the widget is disposed in the Selection event by the user. I have experienced such exception in the past. The fix is to we should check for isDisposed() after we send the selectionEvent. (In reply to comment #2) > I guess the widget is disposed in the Selection event by the user. I think Praveen is right. Here's a test case. Run it and click on the link and you'll get the NPE in the description. ======================= import org.eclipse.swt.*; import org.eclipse.swt.events.*; import org.eclipse.swt.layout.*; import org.eclipse.swt.widgets.*; public class PR324497 { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setSize(100,100); final Shell shell2 = new Shell(display); shell2.setSize(260, 260); GridLayout layout = new GridLayout(1, false); shell2.setLayout(layout); Link link = new Link(shell2, SWT.LEFT); link.setText("This is a <a>link</a>."); link.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { shell2.close(); shell2.dispose(); } }); Label label = new Label(shell2, SWT.LEFT); label.setText("This is a label."); shell.open(); shell2.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } } Created attachment 178359 [details]
Patch
Fixed as Praveen suggested.
Fixed > 20100907. *** Bug 338228 has been marked as a duplicate of this bug. *** *** Bug 339774 has been marked as a duplicate of this bug. *** |