mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Make ui plugin more fault-tolerant when activated in headless mode
This commit is contained in:
parent
6ac289f820
commit
cfea65c227
2 changed files with 24 additions and 13 deletions
|
@ -13,6 +13,7 @@
|
|||
|
||||
package org.eclipse.cdt.internal.ui.editor;
|
||||
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.ISafeRunnable;
|
||||
|
@ -21,7 +22,6 @@ import org.eclipse.core.runtime.OperationCanceledException;
|
|||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.SafeRunner;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.jface.text.Assert;
|
||||
import org.eclipse.ui.IPartListener2;
|
||||
import org.eclipse.ui.IWindowListener;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
|
@ -269,14 +269,16 @@ public final class ASTProvider {
|
|||
* Installs this AST provider.
|
||||
*/
|
||||
void install() {
|
||||
// Create and register activation listener
|
||||
fActivationListener= new ActivationListener();
|
||||
PlatformUI.getWorkbench().addWindowListener(fActivationListener);
|
||||
|
||||
// Ensure existing windows get connected
|
||||
IWorkbenchWindow[] windows= PlatformUI.getWorkbench().getWorkbenchWindows();
|
||||
for (int i= 0, length= windows.length; i < length; i++)
|
||||
windows[i].getPartService().addPartListener(fActivationListener);
|
||||
if (PlatformUI.isWorkbenchRunning()) {
|
||||
// Create and register activation listener
|
||||
fActivationListener= new ActivationListener();
|
||||
PlatformUI.getWorkbench().addWindowListener(fActivationListener);
|
||||
|
||||
// Ensure existing windows get connected
|
||||
IWorkbenchWindow[] windows= PlatformUI.getWorkbench().getWorkbenchWindows();
|
||||
for (int i= 0, length= windows.length; i < length; i++)
|
||||
windows[i].getPartService().addPartListener(fActivationListener);
|
||||
}
|
||||
}
|
||||
|
||||
private void activeEditorChanged(IWorkbenchPart editor) {
|
||||
|
@ -606,9 +608,11 @@ public final class ASTProvider {
|
|||
*/
|
||||
public void dispose() {
|
||||
|
||||
// Dispose activation listener
|
||||
PlatformUI.getWorkbench().removeWindowListener(fActivationListener);
|
||||
fActivationListener= null;
|
||||
if (fActivationListener != null) {
|
||||
// Dispose activation listener
|
||||
PlatformUI.getWorkbench().removeWindowListener(fActivationListener);
|
||||
fActivationListener= null;
|
||||
}
|
||||
|
||||
disposeAST();
|
||||
|
||||
|
|
|
@ -445,11 +445,18 @@ public class CUIPlugin extends AbstractUIPlugin {
|
|||
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
|
||||
*/
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
if (fASTProvider != null) {
|
||||
fASTProvider.dispose();
|
||||
fASTProvider= null;
|
||||
}
|
||||
if (fTextTools != null) {
|
||||
fTextTools.dispose();
|
||||
fTextTools= null;
|
||||
}
|
||||
if (fImageDescriptorRegistry != null)
|
||||
if (fImageDescriptorRegistry != null) {
|
||||
fImageDescriptorRegistry.dispose();
|
||||
fImageDescriptorRegistry= null;
|
||||
}
|
||||
if ( fBuildConsoleManager != null ) {
|
||||
fBuildConsoleManager.shutdown();
|
||||
fBuildConsoleManager = null;
|
||||
|
|
Loading…
Add table
Reference in a new issue