Bug 463981 Move preference loading to UI thread.
authorDoug Schaefer <dschaefer@qnx.com>
Mon, 13 Apr 2015 16:23:48 +0000 (12:23 -0400)
committerGerrit Code Review @ Eclipse.org <gerrit@eclipse.org>
Mon, 13 Apr 2015 17:26:58 +0000 (13:26 -0400)
A couple of lines in the CUIPlugin.start() method load preferences.
This can only be done from the UI thread since it eventually loads up
colors which can only be done on the UI thread. This change moves
those two lines to a UIJob.

Change-Id: I692a81d5a38f63c506dc73da93df6c2e9e4b6192

core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIMessages.java
core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIMessages.properties
core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java

index c50e1e9..94bb2de 100644 (file)
@@ -78,6 +78,7 @@ public final class CUIMessages extends NLS {
        public static String NewCDTProjectWizard_templatePageDesc;
        public static String NewCDTProjectWizard_templatePageTitle;
        public static String NewCDTProjectWizard_windowTitle;
+       public static String CUIPlugin_initPrefs;
 
        static {
                NLS.initializeMessages(BUNDLE_NAME, CUIMessages.class);
index f200d3d..00705b5 100644 (file)
@@ -81,3 +81,5 @@ NewCDTProjectWizard_refPageTitle=Project References
 NewCDTProjectWizard_templatePageDesc=Select a project template for the new project
 NewCDTProjectWizard_templatePageTitle=Project Template
 NewCDTProjectWizard_windowTitle=New C/C++ Project
+
+CUIPlugin_initPrefs=Initialize C/C++ UI Preferences
\ No newline at end of file
index 76d6dac..b234626 100644 (file)
@@ -65,6 +65,7 @@ import org.eclipse.ui.editors.text.templates.ContributionTemplateStore;
 import org.eclipse.ui.navigator.ICommonMenuConstants;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 import org.eclipse.ui.preferences.ScopedPreferenceStore;
+import org.eclipse.ui.progress.UIJob;
 import org.eclipse.ui.texteditor.ChainedPreferenceStore;
 import org.eclipse.ui.texteditor.ConfigurationElementSorter;
 import org.eclipse.ui.texteditor.ITextEditor;
@@ -90,6 +91,7 @@ import org.eclipse.cdt.internal.corext.template.c.DocCommentContextType;
 import org.eclipse.cdt.internal.corext.template.c.FileTemplateContextType;
 
 import org.eclipse.cdt.internal.ui.CElementAdapterFactory;
+import org.eclipse.cdt.internal.ui.CUIMessages;
 import org.eclipse.cdt.internal.ui.ICStatusConstants;
 import org.eclipse.cdt.internal.ui.IContextMenuConstants;
 import org.eclipse.cdt.internal.ui.ResourceAdapterFactory;
@@ -602,10 +604,19 @@ public class CUIPlugin extends AbstractUIPlugin {
                DocCommentOwnerManager.getInstance().addListener(new EditorReopener());
                ASTRewriteAnalyzer.setCTextFileChangeFactory(new CTextFileChangeFactory());
 
-               // A workaround for black console bug 320723.
-               BuildConsolePreferencePage.initDefaults(getPreferenceStore());
-               // Initialize ContentAssistMatcherPreference.
-               ContentAssistPreference.getInstance();
+               // These need to be done on the UI thread
+               UIJob prefsJob = new UIJob(CUIMessages.CUIPlugin_initPrefs) {
+                       @Override
+                       public IStatus runInUIThread(IProgressMonitor monitor) {
+                               // A workaround for black console bug 320723.
+                               BuildConsolePreferencePage.initDefaults(getPreferenceStore());
+                               // Initialize ContentAssistMatcherPreference.
+                               ContentAssistPreference.getInstance();
+                               return Status.OK_STATUS;
+                       }
+               };
+               prefsJob.setSystem(true);
+               prefsJob.schedule();
 
                // Start make.ui plug-in, such that it can check for project conversions.
                Job job= new Job(Messages.CUIPlugin_jobStartMakeUI) {