1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-05 07:15:39 +02:00

Bug 330259 - [disassembly] debug context is not per workbench window

This commit is contained in:
Patrick Chuong 2010-11-24 14:39:28 +00:00
parent 671675293a
commit 9865f25dbc

View file

@ -9,6 +9,7 @@
* Wind River Systems - initial API and implementation
* Patrick Chuong (Texas Instruments) - Bug fix (326670)
* Patrick Chuong (Texas Instruments) - Bug fix (329682)
* Patrick Chuong (Texas Instruments) - bug fix (330259)
*******************************************************************************/
package org.eclipse.cdt.dsf.debug.internal.ui.disassembly;
@ -73,6 +74,7 @@ import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.contexts.DebugContextEvent;
import org.eclipse.debug.ui.contexts.IDebugContextListener;
import org.eclipse.debug.ui.contexts.IDebugContextService;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.IAction;
@ -116,7 +118,9 @@ import org.eclipse.jface.text.source.OverviewRuler;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyleRange;
@ -713,7 +717,8 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
protected void setSite(IWorkbenchPartSite site) {
super.setSite(site);
site.getPage().addPartListener(fPartListener);
DebugUITools.getDebugContextManager().addDebugContextListener(fDebugContextListener = new IDebugContextListener() {
IDebugContextService contextService = DebugUITools.getDebugContextManager().getContextService(site.getWorkbenchWindow());
contextService.addDebugContextListener(fDebugContextListener = new IDebugContextListener() {
public void debugContextChanged(DebugContextEvent event) {
if ((event.getFlags() & DebugContextEvent.ACTIVATED) != 0) {
updateDebugContext();
@ -1841,7 +1846,13 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
}
protected void updateDebugContext() {
IAdaptable context = DebugUITools.getDebugContext();
IDebugContextService contextService = DebugUITools.getDebugContextManager().getContextService(getSite().getWorkbenchWindow());
ISelection activeContext = contextService.getActiveContext();
if (activeContext instanceof IStructuredSelection) {
Object selectedElement = ((IStructuredSelection) activeContext).getFirstElement();
if (selectedElement instanceof IAdaptable) {
IAdaptable context = (IAdaptable) selectedElement;
final IDisassemblyBackend prevBackend = fBackend;
fDebugSessionId = null;
if (context != null) {
@ -1870,6 +1881,8 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
}
}
}
}
}
private void debugContextChanged() {
if (DEBUG) System.out.println("DisassemblyPart.debugContextChanged()"); //$NON-NLS-1$
@ -1965,6 +1978,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
}
private BigInteger getTopAddress() {
if (fViewer != null) {
BigInteger topAddress = getAddressOfLine(fViewer.getTopIndex());
if (topAddress.equals(fStartAddress)) {
// in rare cases, the top line can be '...'
@ -1972,6 +1986,10 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
topAddress = getAddressOfLine(fViewer.getTopIndex() + 1);
}
return topAddress;
} else {
return PC_UNKNOWN;
}
}
private void resetViewer() {