Bug 95658 [Workbench] Events are being dispatched and async/syncExecs are run before the Workbench is in a good state
As part of plug-in startup and activation, anyone can call Display.readAndDispatch() to process UI events. This will also run any outstanding asyncExecs and syncExecs. For example, ModalContext.ModalContextThread#block calls readAndDispatch. This in turn is indirectly called by ProgressManager#run, which is called by CVS's AllRootsElement when the repositories view is created. The code that restores the Workbench is written in a way that it assumes no events are dispatched and no async/syncExecs are run before the 'real' UI event loop runs. This is a false assumption. I am attaching source for a modified UISynchronizer that delays at least the async/syncExecs until it is safe to run them. However, this creates a new problem in that ModalContext.ModalContextThread#block actually blocks forever because the syncExec in ModalContext.ModalContextThread#run is not being executed. We should either be prepared for anyone to call into Workbench methods even before we run the event loop, or use something along the lines of the attached UISycnhronizer to prevent this from happening.
bundles/org.eclipse.jface/src/org/eclipse/jface/operation/ModalContext.java
/*******************************************************************************
 * Copyright (c) 2000, 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jface.operation;
import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.ProgressMonitorWrapper;
import org.eclipse.jface.util.Assert;
import org.eclipse.swt.widgets.Display;
/**
 * Utility class for supporting modal operations.
 * The runnable passed to the <code>run</code> method is executed in a
 * separate thread, depending on the value of the passed fork argument. 
 * If the runnable is executed in a separate thread then the current thread
 * either waits until the new thread ends or, if the current thread is the 
 * UI thread, it polls the SWT event queue and dispatches each event.
 * <p>
 * This class is not intended to be subclassed.
 * </p>
 */
public class ModalContext {