Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPawel Piech2012-12-01 00:02:24 +0000
committerPawel Piech2012-12-01 00:02:48 +0000
commit6969f6131bc0b5b970509047133b72ec67d8b3c0 (patch)
tree88a1f63daaf089464f602d63ae056b2ba9883bf3
parent5fb31ba8cc16508d7badad7188202b782054ab4b (diff)
downloadeclipse.platform.debug-6969f6131bc0b5b970509047133b72ec67d8b3c0.tar.gz
eclipse.platform.debug-6969f6131bc0b5b970509047133b72ec67d8b3c0.tar.xz
eclipse.platform.debug-6969f6131bc0b5b970509047133b72ec67d8b3c0.zip
Bug 327497 - [source lookup] Two debug source look up requests for the same debug session
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupFacility.java103
1 files changed, 66 insertions, 37 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupFacility.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupFacility.java
index 45c9fa2be..7743f5305 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupFacility.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupFacility.java
@@ -46,6 +46,7 @@ import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorReference;
@@ -125,7 +126,6 @@ public class SourceLookupFacility implements IPageListener, IPartListener2, IPro
* @return a source lookup result
*/
public SourceLookupResult lookup(Object artifact, ISourceLocator locator) {
- SourceLookupResult result = new SourceLookupResult(artifact, null, null, null);
IDebugElement debugElement = null;
if (artifact instanceof IDebugElement) {
debugElement = (IDebugElement)artifact;
@@ -140,51 +140,80 @@ public class SourceLookupFacility implements IPageListener, IPartListener2, IPro
}
}
if (locator != null) {
- String editorId =null;
- IEditorInput editorInput = null;
- Object sourceElement = null;
- if (locator instanceof ISourceLookupDirector) {
- ISourceLookupDirector director = (ISourceLookupDirector)locator;
- sourceElement = director.getSourceElement(artifact);
+ // Do not acquire a lock on the locator if in UI thread. This is
+ // because this locator may need to perform a Display.syncExec()
+ // when performing a lookup.
+ if (Display.getCurrent() != null) {
+ return doLookup(artifact, locator);
+ } else {
+ synchronized(locator) {
+ return doLookup(artifact, locator);
+ }
+ }
+ } else {
+ return new SourceLookupResult(artifact, null, null, null);
+ }
+ }
+
+ private SourceLookupResult doLookup(Object artifact, ISourceLocator locator) {
+ SourceLookupResult result = new SourceLookupResult(artifact, null, null, null);
+ String editorId =null;
+ IEditorInput editorInput = null;
+ Object sourceElement = null;
+ // Do not acquire a lock on the locator if in UI thread. This is
+ // because this locator may need to perform a Display.syncExec()
+ // when performing a lookup.
+ if (Display.getCurrent() != null) {
+ sourceElement = getSourceElement(locator, artifact);
+ } else {
+ synchronized(locator) {
+ sourceElement = getSourceElement(locator, artifact);
+ }
+ }
+ if (sourceElement == null) {
+ if (locator instanceof AbstractSourceLookupDirector) {
+ editorInput = new CommonSourceNotFoundEditorInput(artifact);
+ editorId = IDebugUIConstants.ID_COMMON_SOURCE_NOT_FOUND_EDITOR;
} else {
if (artifact instanceof IStackFrame) {
- sourceElement = locator.getSourceElement((IStackFrame)artifact);
+ IStackFrame frame = (IStackFrame)artifact;
+ editorInput = new SourceNotFoundEditorInput(frame);
+ editorId = IInternalDebugUIConstants.ID_SOURCE_NOT_FOUND_EDITOR;
}
}
- if (sourceElement == null) {
- if (locator instanceof AbstractSourceLookupDirector) {
- editorInput = new CommonSourceNotFoundEditorInput(artifact);
- editorId = IDebugUIConstants.ID_COMMON_SOURCE_NOT_FOUND_EDITOR;
- } else {
- if (artifact instanceof IStackFrame) {
- IStackFrame frame = (IStackFrame)artifact;
- editorInput = new SourceNotFoundEditorInput(frame);
- editorId = IInternalDebugUIConstants.ID_SOURCE_NOT_FOUND_EDITOR;
- }
- }
+ } else {
+ ISourcePresentation presentation= null;
+ if (locator instanceof ISourcePresentation) {
+ presentation= (ISourcePresentation) locator;
} else {
- ISourcePresentation presentation= null;
- if (locator instanceof ISourcePresentation) {
- presentation= (ISourcePresentation) locator;
- } else {
- if (debugElement != null) {
- presentation= getPresentation(debugElement.getModelIdentifier());
- }
- }
- if (presentation != null) {
- editorInput= presentation.getEditorInput(sourceElement);
- }
- if (editorInput != null && presentation != null) {
- editorId= presentation.getEditorId(editorInput, sourceElement);
- }
+ if (artifact instanceof IDebugElement) {
+ presentation= getPresentation(((IDebugElement)artifact).getModelIdentifier());
+ }
}
- result.setEditorInput(editorInput);
- result.setEditorId(editorId);
- result.setSourceElement(sourceElement);
+ if (presentation != null) {
+ editorInput= presentation.getEditorInput(sourceElement);
+ }
+ if (editorInput != null && presentation != null) {
+ editorId= presentation.getEditorId(editorInput, sourceElement);
+ }
}
- return result;
+ result.setEditorInput(editorInput);
+ result.setEditorId(editorId);
+ result.setSourceElement(sourceElement);
+ return result;
}
+ private Object getSourceElement(ISourceLocator locator, Object artifact) {
+ if (locator instanceof ISourceLookupDirector) {
+ ISourceLookupDirector director = (ISourceLookupDirector)locator;
+ return director.getSourceElement(artifact);
+ } else {
+ if (artifact instanceof IStackFrame) {
+ return locator.getSourceElement((IStackFrame)artifact);
+ }
+ }
+ return null;
+ }
/**
* Returns the model presentation for the given debug model, or <code>null</code>
* if none.

Back to the top