mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 06:32:10 +02:00
[298929] Guards against NPE at eclipse shutdown
This commit is contained in:
parent
024efc1e22
commit
7b781f5d9b
1 changed files with 13 additions and 7 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue