1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-28 19:35:36 +02:00

fixed NPE on shutdown

This commit is contained in:
David Inglis 2004-05-26 15:09:48 +00:00
parent f7264a67cd
commit 7aa7748a99

View file

@ -1,13 +1,11 @@
/**********************************************************************
* Copyright (c) 2002,2003,2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
/*******************************************************************************
* Copyright (c) 2002,2003,2004 QNX Software Systems and others. All rights
* reserved. This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0 which accompanies this
* distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
* Contributors: QNX Software Systems - Initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.buildconsole;
import java.util.HashMap;
@ -53,8 +51,9 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang
}
/**
* Notifies the console manager that console activity has started on the project
* The manager will open the console if the preference is set to show the console, and notify listeners
* Notifies the console manager that console activity has started on the
* project The manager will open the console if the preference is set to
* show the console, and notify listeners
*/
protected void startConsoleActivity(IProject project) {
Object[] list = listeners.getListeners();
@ -69,8 +68,8 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang
}
/**
* Opens the console view. If the view is already open, it is brought to
* the front.
* Opens the console view. If the view is already open, it is brought to the
* front.
*/
protected void showConsole() {
CUIPlugin.getStandardDisplay().asyncExec(new Runnable() {
@ -140,18 +139,39 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang
}
public void shutdown() {
if (infoColor != null) {
infoColor.dispose();
outputColor.dispose();
errorColor.dispose();
}
ConsolePlugin.getDefault().getConsoleManager().removeConsoles(new org.eclipse.ui.console.IConsole[]{fConsole});
CUIPlugin.getWorkspace().removeResourceChangeListener(this);
CUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
}
private void runUI(Runnable run) {
Display display;
display = Display.getCurrent();
if (display == null) {
display = Display.getDefault();
display.asyncExec(run);
} else {
run.run();
}
}
public void startup() {
fConsole = new BuildConsole(this);
ConsolePlugin.getDefault().getConsoleManager().addConsoles(new org.eclipse.ui.console.IConsole[]{fConsole});
runUI(new Runnable() {
/*
* (non-Javadoc)
*
* @see java.lang.Runnable#run()
*/
public void run() {
// install colors
infoColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_INFO_COLOR);
infoStream = new BuildConsoleStream(fConsole);
@ -162,12 +182,15 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang
errorColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_ERROR_COLOR);
errorStream = new BuildConsoleStream(fConsole);
errorStream.setColor(errorColor);
}
});
CUIPlugin.getWorkspace().addResourceChangeListener(this);
CUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
*/
public void propertyChange(PropertyChangeEvent event) {
@ -217,7 +240,8 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang
}
/**
* Returns the document for the projects console, or <code>null</code> if none.
* Returns the document for the projects console, or <code>null</code> if
* none.
*/
public IDocument getConsoleDocument(IProject project) {
Assert.isNotNull(project);