From 7665c9e36a78ebb4c07876955bf35dd276ff0c5e Mon Sep 17 00:00:00 2001 From: Simeon Andreev Date: Tue, 19 Nov 2024 20:11:49 +0100 Subject: [PATCH] Move workbench running check in ColorManager to prevent SWT errors when headless This change adjusts the check added for Eclipze bugzilla 546205 ticket. The check for running workbench is now done at the start of ColorManager.initializeDefaults(), to prevent the creation of an SWT Display object when in headless mode. See: https://bugs.eclipse.org/bugs//show_bug.cgi?id=546205 Fixes: #1486 --- .../eclipse/pde/internal/ui/editor/text/ColorManager.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/text/ColorManager.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/text/ColorManager.java index 2e33ab5bc2..4bc1dfc0d5 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/text/ColorManager.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/text/ColorManager.java @@ -48,6 +48,9 @@ public static IColorManager getDefault() { } public static void initializeDefaults(IPreferenceStore store) { + if (!PlatformUI.isWorkbenchRunning()) { + return; + } PreferenceConverter.setDefault(store, P_DEFAULT, DEFAULT); PreferenceConverter.setDefault(store, P_PROC_INSTR, PROC_INSTR); PreferenceConverter.setDefault(store, P_STRING, STRING); @@ -61,9 +64,6 @@ public static void initializeDefaults(IPreferenceStore store) { PreferenceConverter.setDefault(store, P_HEADER_ATTRIBUTES, HEADER_ATTRIBUTES); store.setDefault(P_HEADER_ATTRIBUTES + IPDEColorConstants.P_ITALIC_SUFFIX, true); PreferenceConverter.setDefault(store, P_HEADER_ASSIGNMENT, HEADER_ASSIGNMENT); - if (!PlatformUI.isWorkbenchRunning()) { - return; - } try { Display display = PlatformUI.getWorkbench().getDisplay(); Runnable runnable = () -> {