From c410447f12f0ab03b79d229756a1f86c91a020d3 Mon Sep 17 00:00:00 2001 From: Simeon Andreev Date: Mon, 30 Sep 2019 10:29:09 +0200 Subject: [PATCH] Bug 319668 - NPE in indexer CCorePlugin.getCProjectDescription This change ensures code in SelectionListenerWithASTManager does not attempt to compute an AST if the workbench is shutting down. This can result in a NPE in the CDT core plug-in. Change-Id: I3a0f921b3327bab9eab7169591f217c4f4766a70 Signed-off-by: Simeon Andreev --- .../ui/viewsupport/SelectionListenerWithASTManager.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/SelectionListenerWithASTManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/SelectionListenerWithASTManager.java index 91552f75bbd..6c00ecba7a4 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/SelectionListenerWithASTManager.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/SelectionListenerWithASTManager.java @@ -35,6 +35,7 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.ui.ISelectionListener; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.texteditor.ITextEditor; /** @@ -134,7 +135,7 @@ public class SelectionListenerWithASTManager { // Try to acquire the lock while (!monitor.isCanceled() && !fJobLock.acquire(10)) { } - if (!monitor.isCanceled() && isSelectionValid(selection)) { + if (!monitor.isCanceled() && isSelectionValid(selection) && PlatformUI.isWorkbenchRunning()) { return calculateASTandInform(workingCopy, selection, monitor); } } catch (InterruptedException e) {