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

Bug 567701

Summary: "Widget is disposed" after removing form element that has a MessageManager handled decoration
Product: [RT] RAP Reporter: Manuel Mall <manuel.mall>
Component: JFaceAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: ivan
Version: unspecified   
Target Milestone: 3.15 M1   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/c/rap/org.eclipse.rap/+/170494
https://git.eclipse.org/c/rap/org.eclipse.rap.git/commit/?id=2cb62d1d20ac39688c10f94a552db378fd77f88b
Whiteboard:

Description Manuel Mall CLA 2020-10-08 04:19:20 EDT
When a form element that has a decoration managed through MessageManager is dynamically removed from a form the next time a message is added to another control managed by the same MessageManager a "Widget is disposed" exception is thrown as per the stack trace below:

org.eclipse.swt.SWTException: Widget is disposed
	at org.eclipse.swt.SWT.error(SWT.java:3708)
	at org.eclipse.swt.SWT.error(SWT.java:3631)
	at org.eclipse.swt.SWT.error(SWT.java:3602)
	at org.eclipse.swt.widgets.Widget.error(Widget.java:1018)
	at org.eclipse.swt.widgets.Widget.getDisplay(Widget.java:397)
	at org.eclipse.swt.widgets.Widget.isValidThread(Widget.java:972)
	at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:955)
	at org.eclipse.swt.internal.widgets.ControlDecorator.getControl(ControlDecorator.java:196)
	at org.eclipse.jface.fieldassist.ControlDecoration.getControl(ControlDecoration.java:193)
	at org.eclipse.ui.internal.forms.MessageManager$ControlDecorator.isDisposed(MessageManager.java:211)
	at org.eclipse.ui.internal.forms.MessageManager.pruneControlDecorators(MessageManager.java:592)
	at org.eclipse.ui.internal.forms.MessageManager.update(MessageManager.java:502)
	at org.eclipse.ui.internal.forms.MessageManager.updateForm(MessageManager.java:498)
	at org.eclipse.ui.internal.forms.MessageManager.addMessage(MessageManager.java:360)
	at au.net.synergy.wts.ui.fo.electricity.contract.editor.ContractDetailsPage.addMessage(ContractDetailsPage.java:520)
	at au.net.synergy.wts.ui.fo.electricity.contract.editor.ContractDetailsPage.addMessage(ContractDetailsPage.java:503)
	at au.net.synergy.wts.ui.fo.electricity.contract.editor.ContractDetailsPage.validateMandatory(ContractDetailsPage.java:585)
	at au.net.synergy.wts.ui.fo.electricity.contract.editor.ContractPartDetailsPage.validateContractVolumeSource(ContractPartDetailsPage.java:531)
	at au.net.synergy.wts.ui.fo.electricity.contract.editor.ContractPartDetailsPage.validatePage(ContractPartDetailsPage.java:1087)
	at au.net.synergy.wts.ui.fo.electricity.contract.editor.ContractPartDetailsPage.createPartControl(ContractPartDetailsPage.java:363)
	at au.net.synergy.wts.ui.fo.electricity.contract.editor.ContractDetailsPage.addContractPart(ContractDetailsPage.java:651)
	at au.net.synergy.wts.ui.fo.electricity.contract.editor.ContractDetailsPage$2.widgetSelected(ContractDetailsPage.java:295)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:263)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:109)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:687)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:594)
	at org.eclipse.swt.widgets.Display.executeNextEvent(Display.java:1217)
	at org.eclipse.swt.widgets.Display.runPendingMessages(Display.java:1198)
	at org.eclipse.swt.widgets.Display.safeReadAndDispatch(Display.java:1181)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1173)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2733)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2694)
	at org.eclipse.ui.internal.Workbench.access$5(Workbench.java:2530)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:701)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:684)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:157)
	at au.net.synergy.wts.application.rap.Application.start(Application.java:92)
	at org.eclipse.rap.ui.internal.application.EntryPointApplicationWrapper.createUI(EntryPointApplicationWrapper.java:38)
	at org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle.createUI(RWTLifeCycle.java:177)
	at org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle$UIThreadController.run(RWTLifeCycle.java:290)
	at java.base/java.lang.Thread.run(Thread.java:834)
	at org.eclipse.rap.rwt.internal.lifecycle.UIThread.run(UIThread.java:107)
Comment 1 Ivan Furnadjiev CLA 2020-10-08 04:39:47 EDT
Manuel, is it possible to provide simple snippet to reproduce it (or modified Workbench demo)?
Comment 2 Manuel Mall CLA 2020-10-08 04:59:43 EDT
That will take some time. As far as I can tell the problem is that the decorators hashmap in MessageManager keeps a cache of created decorators. There are no dispose listeners attached therefore the map relies on the pruneControlDecorators() method to clean itself up. It is isDisposed() check called from that loop that eventually hits that exception because of a CheckWidget() guard.
Comment 3 Eclipse Genie CLA 2020-10-08 05:25:21 EDT
New Gerrit change created: https://git.eclipse.org/r/c/rap/org.eclipse.rap/+/170494
Comment 4 Ivan Furnadjiev CLA 2020-10-08 05:26:08 EDT
I don't need a snippet anymore. Now I understand the problem. The fix is pending.
Comment 5 Manuel Mall CLA 2020-10-08 05:29:23 EDT
Hi Ivan, thanks - let me know when nightly build is available and I am happy to test / verify.
Comment 7 Ivan Furnadjiev CLA 2020-10-08 06:02:27 EDT
(In reply to comment #5)
> Hi Ivan, thanks - let me know when nightly build is available and I am happy to
> test / verify.
Next nightly build will have the fix in.
Comment 8 Manuel Mall CLA 2020-10-09 04:51:17 EDT
Hi Ivan,

just confirming that the nightly build which includes the fix works fine for us.

Thanks
Comment 9 Ivan Furnadjiev CLA 2020-10-09 04:52:10 EDT
(In reply to Manuel Mall from comment #8)
> Hi Ivan,
> 
> just confirming that the nightly build which includes the fix works fine for
> us.
> 
> Thanks

Good to hear!