From 7b781f5d9baa15bf56be97be030967cf716d23fc Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Tue, 12 Jan 2010 21:09:11 +0000 Subject: [PATCH] [298929] Guards against NPE at eclipse shutdown --- .../commands/ReverseToggleCommandHandler.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/ReverseToggleCommandHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/ReverseToggleCommandHandler.java index cb78bb62e64..23e0471b6a8 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/ReverseToggleCommandHandler.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/ReverseToggleCommandHandler.java @@ -58,20 +58,26 @@ public class ReverseToggleCommandHandler extends DebugCommandHandler implements public ReverseToggleCommandHandler() { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - fContextService = DebugUITools.getDebugContextManager().getContextService(window); - fContextService.addPostDebugContextListener(this); + if (window != null) { + fContextService = DebugUITools.getDebugContextManager().getContextService(window); + if (fContextService != null) { + fContextService.addPostDebugContextListener(this); - // This constructor might be called after the launch, so we must refresh here too. - // This can happen if we activate the action set after the launch. - refresh(fContextService.getActiveContext()); + // This constructor might be called after the launch, so we must refresh here too. + // This can happen if we activate the action set after the launch. + refresh(fContextService.getActiveContext()); + } + } } @Override public void dispose() { - // Must use the stored service. If we try to fetch the service + // Must use the stored context service. If we try to fetch the service // again with the workbenchWindow, it may fail if the window is // already closed. - fContextService.removePostDebugContextListener(this); + if (fContextService != null) { + fContextService.removePostDebugContextListener(this); + } fTargetAdapter = null; super.dispose(); }