Bug 186344 [CommonNavigator] Project Explorer duplicates Working Set actions
M7 The Project Explorer sometimes creates duplicate Working Set related view menu items. This seems to be triggered by "Link with Editor" on startup where two instances of WorkingSetActionProvider are created and initialized. The following is a stack trace at the point where the WorkingSetActionProvider adds its actions. Note the recursion starting in NavigatorActionService.getActionProviderInstance() Thread [main] (Suspended (breakpoint at line 277 in WorkingSetActionProvider)) owns: HashMap<K,V> (id=142) owns: RunnableLock (id=143) WorkingSetActionProvider.fillActionBars(IActionBars) line: 277 NavigatorActionService.initialize(String, CommonActionProvider) line: 353 NavigatorActionService.getActionProviderInstance(CommonActionProviderDescriptor) line: 332 NavigatorActionService.fillActionBars(IActionBars) line: 236 CommonNavigatorManager.selectionChanged(SelectionChangedEvent) line: 217 Viewer$2.run() line: 162 SafeRunner.run(ISafeRunnable) line: 37 Platform.run(ISafeRunnable) line: 850 JFaceUtil$1.run(ISafeRunnable) line: 46 SafeRunnable.run(ISafeRunnable) line: 193 CommonViewer(Viewer).fireSelectionChanged(SelectionChangedEvent) line: 160 CommonViewer(StructuredViewer).updateSelection(ISelection) line: 2039 CommonViewer(StructuredViewer).handleInvalidSelection(ISelection, ISelection) line: 1102 CommonViewer(StructuredViewer).preservingSelection(Runnable, boolean) line: 1376 CommonViewer(TreeViewer).preservingSelection(Runnable, boolean) line: 377 CommonViewer(StructuredViewer).preservingSelection(Runnable) line: 1325 CommonViewer(AbstractTreeViewer).inputChanged(Object, Object) line: 1417 CommonViewer(ContentViewer).setInput(Object) line: 251 CommonViewer(StructuredViewer).setInput(Object) line: 1601 WorkingSetActionProvider.restoreState(IMemento) line: 237 NavigatorActionService.initialize(String, CommonActionProvider) line: 350 NavigatorActionService.getActionProviderInstance(CommonActionProviderDescriptor) line: 332 NavigatorActionService.fillActionBars(IActionBars) line: 236 CommonNavigatorManager.selectionChanged(SelectionChangedEvent) line: 217 Viewer$2.run() line: 162 SafeRunner.run(ISafeRunnable) line: 37 Platform.run(ISafeRunnable) line: 850 JFaceUtil$1.run(ISafeRunnable) line: 46 SafeRunnable.run(ISafeRunnable) line: 193 CommonViewer(Viewer).fireSelectionChanged(SelectionChangedEvent) line: 160 CommonViewer(StructuredViewer).updateSelection(ISelection) line: 2039 CommonViewer(StructuredViewer).setSelection(ISelection, boolean) line: 1636 CommonViewer(TreeViewer).setSelection(ISelection, boolean) line: 1031 CommonViewer.setSelection(ISelection, boolean) line: 325 CommonNavigator.selectReveal(ISelection) line: 313 LinkEditorAction$2.runInUIThread(IProgressMonitor) line: 91 UIJob$1.run() line: 94 [...]
bundles/org.eclipse.ui.navigator/src/org/eclipse/ui/navigator/NavigatorActionService.java
CommonActionProvider element = (CommonActionProvider) iter.next();
				element.dispose();
			}
			actionProviderInstances.clear();
		}
		actionProviderDescriptors.clear();
		disposed = false;
	}
	/**
	 * Use the given memento to restore the state of each Action Provider as it is initialized.
	 * 
	 * @param aMemento
	 *            The memento retrieved from the dialog settings
	 */
	public void restoreState(IMemento aMemento) {
		Assert.isTrue(!disposed);
		memento = aMemento;
		synchronized (actionProviderInstances) {
			for (Iterator actionProviderIterator = actionProviderInstances.values().iterator(); actionProviderIterator.hasNext();) {
				final CommonActionProvider provider = (CommonActionProvider) actionProviderIterator.next();
				ISafeRunnable runnable = new ISafeRunnable() {
					public void run() throws Exception {
						provider.restoreState(memento);
					}
					public void handleException(Throwable exception) {
						NavigatorPlugin.logError(0, "Could not restore state for action provider " + provider.getClass(), exception); 
					}
				};
				SafeRunner.run(runnable);
			}