Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 93289

Summary: Widget is Disposed error when disposing Link in focusOut callback
Product: [Eclipse Project] Platform Reporter: Grant Gayed <grant_gayed>
Component: SWTAssignee: Felipe Heidrich <eclipse.felipe>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, ericwill, yevshif
Version: 3.1Keywords: triaged
Target Milestone: ---   
Hardware: PC   
OS: Linux-GTK   
Whiteboard:

Description Grant Gayed CLA 2005-04-29 12:32:05 EDT
I0426

Run the snippet at the bottom and hover over the Shell.  You'll get the
following exception (note that you'll also get some gtk error spew, but this is
a separate gtk bug, logged as http://bugs.gnome.org/show_bug.cgi?id=302445 ):

Exception in thread "main" org.eclipse.swt.SWTException: Widget is disposed
	at org.eclipse.swt.SWT.error(SWT.java:2940)
	at org.eclipse.swt.SWT.error(SWT.java:2863)
	at org.eclipse.swt.SWT.error(SWT.java:2834)
	at org.eclipse.swt.widgets.Widget.error(Widget.java:402)
	at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:338)
	at org.eclipse.swt.widgets.Control.redraw(Control.java:2324)
	at org.eclipse.swt.widgets.Link.gtk_event_after(Link.java:287)
	at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:1343)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:3341)
	at org.eclipse.swt.internal.gtk.OS._gtk_widget_set_sensitive(Native Method)
	at org.eclipse.swt.internal.gtk.OS.gtk_widget_set_sensitive(OS.java:7143)
	at org.eclipse.swt.widgets.Control.enableWidget(Control.java:109)
	at org.eclipse.swt.widgets.Link.enableWidget(Link.java:161)
	at org.eclipse.swt.widgets.Control.setEnabled(Control.java:2626)
	at win32.Main0$1.handleEvent(Main0.java:18)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1012)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2780)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2474)
	at win32.Main0.main(Main0.java:29)

snippet:

public static void main(String[] args) {
	final Display display = new Display();
	Shell shell = new Shell(display);
	shell.setBounds(10, 10, 200, 200);
	final Link link = new Link(shell, SWT.PUSH);
	link.setBounds(10,10,50,50);
	link.setText("abc");
	final Button button = new Button(shell, SWT.PUSH);
	button.setBounds(10,100,50,50);
	shell.addListener(SWT.MouseHover, new Listener() {
		public void handleEvent(Event event) {
			link.setEnabled(false);
		}
	});
	link.addListener(SWT.FocusOut, new Listener() {
		public void handleEvent(Event event) {
			link.dispose();
		}
	});
	shell.open();
	link.setFocus();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) display.sleep();
	}
	display.dispose();
}
Comment 1 Eric Williams CLA 2018-04-13 15:31:56 EDT
I can't reproduce this on GTK3.22, 4.8 M6, and Fedora 27.
Comment 2 Eric Williams CLA 2018-05-15 15:54:07 EDT
*** Bug 319751 has been marked as a duplicate of this bug. ***