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

Bug 364661

Summary: In DeferredTreeContentManager - ProgressMessages.get() called out of UI Context
Product: [RT] RAP Reporter: Imrich Schindler <imrich.schindler>
Component: WorkbenchAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: mcnaggets, mleone
Version: unspecified   
Target Milestone: 2.2 RC1   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Patch
none
Proposed patch.
none
Proposed Patch none

Description Imrich Schindler CLA 2011-11-23 17:36:02 EST
Created attachment 207450 [details]
Patch

All ProgressMessages.get() calls are called out of UI Context

If I call ProgressMessages.get() when object DeferredTreeContentManager is created an assign return values into local variables and in next code use this variables, all is ok.

Patch is attached.

Example trace log:

org.eclipse.swt.SWTException: Invalid thread access
	at org.eclipse.swt.SWT.error(SWT.java:3533) ~[na:na]
	at org.eclipse.swt.SWT.error(SWT.java:3456) ~[na:na]
	at org.eclipse.swt.SWT.error(SWT.java:3427) ~[na:na]
	at org.eclipse.rwt.RWT.checkHasSessionContext(RWT.java:387) ~[na:na]
	at org.eclipse.rwt.RWT.getLocale(RWT.java:324) ~[na:na]
	at org.eclipse.rwt.RWT$NLS.getISO8859_1Encoded(RWT.java:108) ~[na:na]
	at org.eclipse.ui.internal.progress.ProgressMessages.get(ProgressMessages.java:138) ~[na:na]
	at org.eclipse.ui.progress.DeferredTreeContentManager.runClearPlaceholderJob(DeferredTreeContentManager.java:385) ~[na:na]
	at org.eclipse.ui.progress.DeferredTreeContentManager$2.done(DeferredTreeContentManager.java:295) ~[na:na]
	at org.eclipse.core.internal.jobs.JobListeners$3.notify(JobListeners.java:39) ~[na:na]
	at org.eclipse.core.internal.jobs.JobListeners.doNotify(JobListeners.java:112) ~[na:na]
	at org.eclipse.core.internal.jobs.JobListeners.done(JobListeners.java:152) ~[na:na]
	at org.eclipse.core.internal.jobs.JobManager.endJob(JobManager.java:647) ~[na:na]
	at org.eclipse.core.internal.jobs.WorkerPool.endJob(WorkerPool.java:105) ~[na:na]
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:71) ~[na:na]
Comment 1 Ivan Furnadjiev CLA 2011-12-22 07:13:59 EST
Created attachment 208729 [details]
Proposed patch.

This patch uses the same technique like in other places (FilteredItemsSelectionDialog for example) in the Workbench - access messages with fake context.
Comment 2 Ivan Furnadjiev CLA 2011-12-22 07:15:58 EST
Imrich, could you try the attached patch?
Comment 3 Maxim Proborschuk CLA 2013-07-05 03:23:51 EDT
What is the status of this bug?
In RAP 2.1 it is still actual.
Comment 4 Mark Leone CLA 2013-11-20 16:47:54 EST
Created attachment 237599 [details]
Proposed Patch

Relative to code as modified by patch contributed in this thread by Ivan.
Comment 5 Mark Leone CLA 2013-11-20 16:51:59 EST
Comment on attachment 237599 [details]
Proposed Patch

The proposed patch I submitted shows what I needed to do to make Ivan's patch work in my app. See forum thread http://www.eclipse.org/forums/index.php/mn/msg/607213/1/on/0/?SQ=ad7b2861d6d8f3391c192ae811d046e1 for further explanation.
Comment 6 Ivan Furnadjiev CLA 2013-11-21 11:29:44 EST
Fixed in master with commit f8a286b305cd65959c562767120fabd017255783. Mark, I didn't change the execution of "adapter.fetchDeferredChildren" as you suggested. It is still executed in background thread.