Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 323704 - [CommonNavigator] Refresh problem in Project Explorer
Summary: [CommonNavigator] Refresh problem in Project Explorer
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.6.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform UI Triaged CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-26 09:17 EDT by aytac CLA
Modified: 2019-11-14 02:13 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description aytac CLA 2010-08-26 09:17:05 EDT
Build Identifier: M20090917-0800


I have a custom project wizard which creates a given number of projects. If the wizard is canceled during the creation of projects, I want to delete the projects which are created between pressing the finish and cancel buttons. So, I call the newProjects[i].delete() in a for loop when cancel is pressed. Projects are deleted from the workspace but, sometimes they are still visible in project explorer. when i refresh project explorer manually they dissappear. In package explorer it works fine. My eclipse version is 3.5.1

I debugged and saw that sometimes, projects are deleted before they are added to the elementMap of the viewer. So, in AbstractTreeViewr's internalRemove(Object[]) method elements can't be found and the widgets for the deleted projects aren't disposed. It seems a syncronization problem.

After adding/deleting resources processDelta method In ResourceExtensionContentProvider class is called for the updates. If we are not in UI thread, runUpdates in Display.asyncExec(). When syncExec is used in stead of asyncExec the problem is resolved. But I don't know why asyncExec is used and what if change it to syncExec.

	protected void processDelta(IResourceDelta delta) {		

		Control ctrl = viewer.getControl();
		if (ctrl == null || ctrl.isDisposed()) {
			return;
		}
		final Collection runnables = new ArrayList();
		processDelta(delta, runnables);

		if (runnables.isEmpty()) {
			return;
		}

		//Are we in the UIThread? If so spin it until we are done
		if (ctrl.getDisplay().getThread() == Thread.currentThread()) {
			runUpdates(runnables);
		} else {
			ctrl.getDisplay().asyncExec(new Runnable(){
				public void run() {
					Control ctrl = viewer.getControl();
					if (ctrl == null || ctrl.isDisposed()) {
						return;
					}
					
					runUpdates(runnables);
				}
			});
		}

	}


Reproducible: Sometimes
Comment 1 Francis Upton IV CLA 2011-04-21 03:15:55 EDT
(In reply to comment #0)
>  But I don't know why asyncExec is used
> and what if change it to syncExec.

Changing it to syncExec will likely introduce deadlocks. The resource notifications can happen on any thread and must be handled quickly as they are done under the locking associated with resources. Forcing a sync switch back to the UI thread is not something allowed in this situation.

I'm not sure what you might have in mind as far as additional synchronization to prevent these problems. If you have further ideas, please do comment.
Comment 2 Lars Vogel CLA 2019-11-14 02:13:41 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

If the bug is still relevant, please remove the "stalebug" whiteboard tag.