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