aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDawid Pakuła2018-07-19 16:49:53 -0400
committerDawid Pakuła2018-07-19 16:49:53 -0400
commit809e30ec2527e3a346e10983ab2ffacaacdbc61a (patch)
treeebbd2718d47ed1e4e956a45bf56bdfe26af0b799
parentf19e5baff96f584388429216b248180bd7dc4c7c (diff)
downloadorg.eclipse.pdt-809e30ec2527e3a346e10983ab2ffacaacdbc61a.tar.gz
org.eclipse.pdt-809e30ec2527e3a346e10983ab2ffacaacdbc61a.tar.xz
org.eclipse.pdt-809e30ec2527e3a346e10983ab2ffacaacdbc61a.zip
No bug - Avoid potential deadlock in outline selection events
Signed-off-by: Dawid Pakuła <zulus@w3des.net>
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/PHPStructuredEditor.java31
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/outline/PHPContentOutlineConfiguration.java10
2 files changed, 24 insertions, 17 deletions
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/PHPStructuredEditor.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/PHPStructuredEditor.java
index 9d00b4a02..ecfc75cf1 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/PHPStructuredEditor.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/PHPStructuredEditor.java
@@ -3714,15 +3714,16 @@ public class PHPStructuredEditor extends StructuredTextEditor {
final int[] caret = new int[1];
if (sourceViewer instanceof ITextViewerExtension5) {
final ITextViewerExtension5 extension = (ITextViewerExtension5) sourceViewer;
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- if (!styledText.isDisposed()) {
- caret[0] = extension.widgetOffset2ModelOffset(styledText.getCaretOffset());
- }
+ Runnable caretRunnable = () -> {
+ if (!styledText.isDisposed()) {
+ caret[0] = extension.widgetOffset2ModelOffset(styledText.getCaretOffset());
}
- });
-
+ };
+ if (Display.getCurrent() != null) {
+ caretRunnable.run();
+ } else {
+ Display.getDefault().syncExec(caretRunnable);
+ }
} else {
int offset = sourceViewer.getVisibleRegion().getOffset();
caret[0] = offset + styledText.getCaretOffset();
@@ -3740,12 +3741,14 @@ public class PHPStructuredEditor extends StructuredTextEditor {
return;
}
final ISelection[] selection = new ISelection[1];
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- selection[0] = getSelectionProvider().getSelection();
- }
- });
+ Runnable getSelection = () -> {
+ selection[0] = getSelectionProvider().getSelection();
+ };
+ if (Display.getCurrent() != null) {
+ getSelection.run();
+ } else {
+ Display.getDefault().syncExec(getSelection);
+ }
if (selection[0] == null) {
return;
}
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/outline/PHPContentOutlineConfiguration.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/outline/PHPContentOutlineConfiguration.java
index b413f718c..83f68e436 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/outline/PHPContentOutlineConfiguration.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/outline/PHPContentOutlineConfiguration.java
@@ -291,9 +291,12 @@ public class PHPContentOutlineConfiguration extends HTMLContentOutlineConfigurat
if (lastSelection instanceof IStructuredSelection && lastSelection instanceof TextSelection) {
IEditorPart activeEditor = PHPUiPlugin.getActiveEditor();
if (activeEditor instanceof PHPStructuredEditor) {
- ISourceReference computedSourceReference = ((PHPStructuredEditor) activeEditor)
- .computeHighlightRangeSourceReference();
- if (computedSourceReference != null) {
+ ISelection editorSelection = ((PHPStructuredEditor) activeEditor).getSelectionProvider()
+ .getSelection();
+ if (editorSelection instanceof IStructuredSelection && ((IStructuredSelection) editorSelection)
+ .getFirstElement() instanceof ISourceReference) {
+ ISourceReference computedSourceReference = (ISourceReference) ((IStructuredSelection) editorSelection)
+ .getFirstElement();
Object parent = ((PHPOutlineContentProvider) contentProvider)
.getParent(computedSourceReference);
for (Object element : ((PHPOutlineContentProvider) contentProvider).getChildren(parent)) {
@@ -305,6 +308,7 @@ public class PHPContentOutlineConfiguration extends HTMLContentOutlineConfigurat
lastSelection = new StructuredSelection(parent);
return lastSelection;
}
+
}
}
}