1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-31 21:05:37 +02:00

Bug 474946 - Initialization Code must be run asynchronously

Do the initialization asynchronously. If the service was initialized
during this class gets instantiated, it was re-instantiated and so a
StackOverflowException was produced. Now the initialization is done
asynchronously.

Bug: 474946
Change-Id: I15356c5f6e450d825d4f8615e2fba177409f5894
Signed-off-by: Martin Schreiber <m.schreiber@bachmann.info>
This commit is contained in:
Martin Schreiber 2015-09-21 15:30:21 +02:00 committed by Anton Leherbauer
parent e38a038340
commit 2cf6b41bd2

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2010, 2011 Ericsson and others. * Copyright (c) 2010, 2015 Ericsson and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -63,18 +63,24 @@ public class ReverseToggleCommandHandler extends DebugCommandHandler implements
private IDebugContextService fContextService = null; private IDebugContextService fContextService = null;
public ReverseToggleCommandHandler() { public ReverseToggleCommandHandler() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window != null) { if (window != null) {
fContextService = DebugUITools.getDebugContextManager().getContextService(window); window.getShell().getDisplay().asyncExec(new Runnable() {
if (fContextService != null) {
fContextService.addPostDebugContextListener(this);
// This constructor might be called after the launch, so we must refresh here too. @Override
// This can happen if we activate the action set after the launch. public void run() {
refresh(fContextService.getActiveContext()); fContextService = DebugUITools.getDebugContextManager().getContextService(window);
} if (fContextService != null) {
} fContextService.addPostDebugContextListener(ReverseToggleCommandHandler.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());
}
}
});
}
}
@Override @Override
public void dispose() { public void dispose() {