Bug 509829 - SWTException below EngineResultSection.lambda$0 (thrown in
Widget.getDisplay)

Change-Id: Ia8fc4a31737967ee930a03dd5244218dfb6acc0a
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineResultSection.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineResultSection.java
index d6e1631..8ef81fa 100644
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineResultSection.java
+++ b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineResultSection.java
@@ -59,9 +59,9 @@
 public class EngineResultSection {
 
 	private static final String KEY_PREFIX_GRAYED = "grayed:"; //$NON-NLS-1$
-	
+
 	private static final String CAT_HEADING_PREFIX = "catheading:"; //$NON-NLS-1$
-	
+
 	private SearchResultsPart part;
 
 	private EngineDescriptor desc;
@@ -227,7 +227,7 @@
 
 	/*
 	 * (non-Javadoc)
-	 * 
+	 *
 	 * @see org.eclipse.help.internal.search.federated.ISearchEngineResultCollector#add(org.eclipse.help.internal.search.federated.ISearchEngineResult[])
 	 */
 	public synchronized void add(ISearchEngineResult[] matches) {
@@ -259,7 +259,10 @@
 	}
 
 	private void asyncUpdateResults(boolean now, final boolean scrollToBeginning) {
-		Runnable runnable = () -> BusyIndicator.showWhile(section.getDisplay(), () -> {
+		Runnable runnable = () -> BusyIndicator.showWhile(PlatformUI.getWorkbench().getDisplay(), () -> {
+			if (section.isDisposed()) {
+				return;
+			}
 			updateResults(true);
 			if (scrollToBeginning) {
 				searchResults.setFocus();
@@ -267,12 +270,14 @@
 				part.updateSeparatorVisibility();
 			}
 		});
-		if (section.isDisposed())
+		if (section.isDisposed()) {
 			return;
-		if (now)
-			section.getDisplay().syncExec(runnable);
-		else
-			section.getDisplay().asyncExec(runnable);
+		}
+		if (now) {
+			PlatformUI.getWorkbench().getDisplay().syncExec(runnable);
+		} else {
+			PlatformUI.getWorkbench().getDisplay().asyncExec(runnable);
+		}
 	}
 
 	private ISearchEngineResult[] getResults() {
@@ -292,11 +297,11 @@
 			sorter.sort(null, results);
 		return results;
 	}
-	
+
 	/**
 	 * Returns a copy of the given image but grayed and half transparent.
 	 * This gives the icon a grayed/disabled look.
-	 * 
+	 *
 	 * @param image the image to gray
 	 * @return the grayed image
 	 */
@@ -380,11 +385,11 @@
 						imageId = id;
 				}
 			}
-			
+
 			if (isPotentialHit) {
 				imageId = KEY_PREFIX_GRAYED + imageId;
 			}
-			
+
 			buff.append(imageId);
 			buff.append("\">"); //$NON-NLS-1$
 			buff.append("<a href=\""); //$NON-NLS-1$
@@ -416,7 +421,7 @@
 			else {
 				elabel = hit.getLabel();
 			}
-			
+
 			elabel = EscapeUtils.escapeSpecialChars(elabel);
 			buff.append(elabel);
 			buff.append("</a>"); //$NON-NLS-1$
@@ -444,7 +449,7 @@
 	 * Registers the given icon URL for use with this section. Icons
 	 * must be registered before use and referenced by the returned
 	 * ID.
-	 * 
+	 *
 	 * @param iconURL the URL to the icon
 	 * @return the ID to use for referencing the icon
 	 */
@@ -461,7 +466,7 @@
 	 * Same as registerHitIcon() but to register a grayed icon. You
 	 * can provide the same URL for both the regular and grayed icons,
 	 * but two different IDs will be returned.
-	 * 
+	 *
 	 * @param iconURL the URL to the icon
 	 * @return the ID to use for referencing the icon
 	 */