Bug 552961 - Eclipse stalls after start
Do not try to use syncExec() in preference initializer, this can lead to
deadlocks on startup.
Change-Id: I33bbbeea17edb98d662fb7bd41139996144c28a1
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/PreferenceConstants.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/PreferenceConstants.java
index c955581..595af28 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/PreferenceConstants.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/PreferenceConstants.java
@@ -3,7 +3,7 @@
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
- *
+ *
* SPDX-License-Identifier: EPL-2.0
*
*******************************************************************************/
@@ -518,9 +518,19 @@
new RGB(237, 233, 227));
return;
}
- final RGB rgb[] = new RGB[1];
- display.syncExec(() -> rgb[0] = display.getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB());
- PreferenceConverter.setValue(store, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR, rgb[0]);
+
+ Runnable uiTask = () -> {
+ final RGB rgb = display.getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB();
+ PreferenceConverter.setValue(store, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR, rgb);
+ };
+
+ if (Display.getCurrent() != null) {
+ // In UI thread call the code directly
+ uiTask.run();
+ } else {
+ // Note: do not try to use syncExec(), this can lead to deadlocks on startup.
+ display.asyncExec(uiTask);
+ }
}
/**