1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

[298929] Guards against NPE at eclipse shutdown

This commit is contained in:
Marc Khouzam 2010-01-12 21:09:11 +00:00
parent 024efc1e22
commit 7b781f5d9b

View file

@ -58,20 +58,26 @@ public class ReverseToggleCommandHandler extends DebugCommandHandler implements
public ReverseToggleCommandHandler() { public ReverseToggleCommandHandler() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window != null) {
fContextService = DebugUITools.getDebugContextManager().getContextService(window); fContextService = DebugUITools.getDebugContextManager().getContextService(window);
if (fContextService != null) {
fContextService.addPostDebugContextListener(this); fContextService.addPostDebugContextListener(this);
// This constructor might be called after the launch, so we must refresh here too. // 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. // This can happen if we activate the action set after the launch.
refresh(fContextService.getActiveContext()); refresh(fContextService.getActiveContext());
} }
}
}
@Override @Override
public void dispose() { 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 // again with the workbenchWindow, it may fail if the window is
// already closed. // already closed.
if (fContextService != null) {
fContextService.removePostDebugContextListener(this); fContextService.removePostDebugContextListener(this);
}
fTargetAdapter = null; fTargetAdapter = null;
super.dispose(); super.dispose();
} }