Community
Participate
Working Groups
SWTException when disposing a ImageHyperlink on linkActivated event. Note, this symptom is only reproducible in Eclipse 3.4.1. Also, defect #242902 may be related in some way, given the similarity in stack traces. Using the below sample code, disposing a ImageHyperlink when the link is clicked (linkActivated event), the following exception is thrown: Exception in thread "main" org.eclipse.swt.SWTException: Widget is disposed at org.eclipse.swt.SWT.error(SWT.java:3777) at org.eclipse.swt.SWT.error(SWT.java:3695) at org.eclipse.swt.SWT.error(SWT.java:3666) at org.eclipse.swt.widgets.Widget.error(Widget.java:463) at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:336) at org.eclipse.swt.widgets.Control.getAccessible(Control.java:1022) at org.eclipse.ui.forms.widgets.AbstractHyperlink.triggerAccessible(AbstractHyperlink.java:235) at org.eclipse.ui.forms.widgets.AbstractHyperlink.handleActivate(AbstractHyperlink.java:231) at org.eclipse.ui.forms.widgets.ImageHyperlink.handleActivate(ImageHyperlink.java:177) at org.eclipse.ui.forms.widgets.AbstractHyperlink.handleMouseUp(AbstractHyperlink.java:320) at org.eclipse.ui.forms.widgets.AbstractHyperlink.access$2(AbstractHyperlink.java:304) at org.eclipse.ui.forms.widgets.AbstractHyperlink$4.handleEvent(AbstractHyperlink.java:119) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3823) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3422) at org.eclipse.hyades.test.ui.extensions.internal.Snippet183.main(Snippet183.java:33) Sample code: public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); ImageHyperlink removeRecordLink = new ImageHyperlink(shell, (SWT.NONE | Window.getDefaultOrientation())); removeRecordLink.setImage(display.getSystemImage (SWT.ICON_ERROR)); removeRecordLink.setSize(50, 50); removeRecordLink.addHyperlinkListener(new HyperlinkAdapter(){ public void linkActivated(HyperlinkEvent hyperlinkEvent){ //Dispose the ImageHyperlink: ((ImageHyperlink)(hyperlinkEvent.getSource())).dispose(); } }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
This has also been reported in bug 250505. A patch was provided in that bug, so I'll close this one as a duplicate. A fix has been delivered to both HEAD (for 3.5 M3) and R3_4_maintenance (for 3.4.2). *** This bug has been marked as a duplicate of bug 250505 ***
Verified in N20081014-2000. Closing.