Bug 125560 [Viewers] Invalid thread access on tree viewer results in NPE
I peformed an update to a tree viewer from a non-UI thread which resulted in an Invalid Thread Access error as one would expect. However, the viewer tried to prompt for the error which resulted in an NPE since the prompt was being attempted from a non-UI thread (or, at least, I assume that's why the display variable was null). Hre's the trace: java.lang.NullPointerException at org.eclipse.jface.dialogs.IconAndMessageDialog.getSWTImage(IconAndMessageDialog.java:265) at org.eclipse.jface.dialogs.IconAndMessageDialog.getErrorImage(IconAndMessageDialog.java:212) at org.eclipse.jface.dialogs.MessageDialog.<init>(MessageDialog.java:141) at org.eclipse.jface.dialogs.MessageDialog.openError(MessageDialog.java:310) at org.eclipse.jface.util.SafeRunnable.handleException(SafeRunnable.java:59) at org.eclipse.core.runtime.SafeRunner.handleException(SafeRunner.java:65) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:39) at org.eclipse.core.runtime.Platform.run(Platform.java:785) at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:44) at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:148) at org.eclipse.jface.viewers.StructuredViewer.updateItem(StructuredViewer.java:1859) at org.eclipse.jface.viewers.StructuredViewer.internalUpdate(StructuredViewer.java:1842) at org.eclipse.jface.viewers.StructuredViewer.update(StructuredViewer.java:1792) at org.eclipse.jface.viewers.StructuredViewer.update(StructuredViewer.java:1747) at org.eclipse.team.internal.ui.mapping.ResourceTeamAwareContentProvider.propertyChanged(ResourceTeamAwareContentProvider.java:233) at org.eclipse.team.core.diff.provider.DiffTree$1.run(DiffTree.java:254) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37) at org.eclipse.core.runtime.Platform.run(Platform.java:785) at org.eclipse.team.core.diff.provider.DiffTree.fireChanges(DiffTree.java:242) at org.eclipse.team.core.diff.provider.DiffTree.endInput(DiffTree.java:220) at org.eclipse.team.internal.core.subscribers.SubscriberDiffTreeEventHandler.dispatchEvents(SubscriberDiffTreeEventHandler.java:162) at org.eclipse.team.internal.core.subscribers.SubscriberEventHandler.doDispatchEvents(SubscriberEventHandler.java:390) at org.eclipse.team.internal.core.BackgroundEventHandler.dispatchEvents(BackgroundEventHandler.java:354) at org.eclipse.team.internal.core.BackgroundEventHandler.processEvents(BackgroundEventHandler.java:334) at org.eclipse.team.internal.core.BackgroundEventHandler$1.run(BackgroundEventHandler.java:173) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)
bundles/org.eclipse.jface/src/org/eclipse/jface/util/SafeRunnable.java
*/
	public void handleException(Throwable e) {
		
		
		if (!ignoreErrors) {
			if (message == null)
				message = JFaceResources.getString("SafeRunnable.errorMessage"); 
			IStatus status = new Status(IStatus.ERROR, Policy.JFACE, message,e);
			if (dialog == null || dialog.getShell().isDisposed()) {
				dialog = new SafeRunnableDialog(status);
				dialog.create();
				dialog.getShell().addDisposeListener(new DisposeListener() {
					/*
					 * (non-Javadoc)
					 * 
					 * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
					 */
					public void widgetDisposed(DisposeEvent e) {
						dialog = null;
					}
				});
				dialog.open();
			} else {
				dialog.addStatus(status);
				dialog.refresh();
			}
		}
	}
	/**
	 * Flag to avoid interactive error dialogs during automated testing.