Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 250461 - [Forms] SWTException when disposing a ImageHyperlink on linkActivated event.
Summary: [Forms] SWTException when disposing a ImageHyperlink on linkActivated event.
Status: CLOSED DUPLICATE of bug 250505
Alias: None
Product: Platform
Classification: Eclipse Project
Component: User Assistance (show other bugs)
Version: 3.4.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: platform-ua-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 247643
  Show dependency tree
 
Reported: 2008-10-10 12:00 EDT by Paul Slauenwhite CLA
Modified: 2008-10-15 08:14 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Slauenwhite CLA 2008-10-10 12:00:21 EDT
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();
	}
Comment 1 Adam Archer CLA 2008-10-14 15:26:17 EDT
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 ***
Comment 2 Paul Slauenwhite CLA 2008-10-15 08:14:04 EDT
Verified in N20081014-2000.

Closing.