1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-31 04:45:38 +02:00

fixed NPE in build console when console manager was not finsihed being initialized and the console was being written to.

This commit is contained in:
David Inglis 2004-05-31 14:13:50 +00:00
parent 01619cd230
commit 92b484a970
3 changed files with 39 additions and 45 deletions

View file

@ -163,6 +163,9 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang
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});
infoStream = new BuildConsoleStream(fConsole);
outputStream = new BuildConsoleStream(fConsole);
errorStream = new BuildConsoleStream(fConsole);
runUI(new Runnable() { runUI(new Runnable() {
@ -174,13 +177,10 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang
public void 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.setColor(infoColor); infoStream.setColor(infoColor);
outputColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_OUTPUT_COLOR); outputColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_OUTPUT_COLOR);
outputStream = new BuildConsoleStream(fConsole);
outputStream.setColor(outputColor); outputStream.setColor(outputColor);
errorColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_ERROR_COLOR); errorColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_ERROR_COLOR);
errorStream = new BuildConsoleStream(fConsole);
errorStream.setColor(errorColor); errorStream.setColor(errorColor);
} }
}); });

View file

@ -234,7 +234,7 @@ public class BuildConsolePage extends Page implements ISelectionListener, IPrope
action.setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor( action.setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(
ISharedImages.IMG_TOOL_COPY_DISABLED)); ISharedImages.IMG_TOOL_COPY_DISABLED));
action.setHoverImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor( action.setHoverImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(
ISharedImages.IMG_TOOL_COPY_HOVER)); ISharedImages.IMG_TOOL_COPY));
setGlobalAction(actionBars, ActionFactory.COPY.getId(), action); setGlobalAction(actionBars, ActionFactory.COPY.getId(), action);
action = new TextViewerAction(getViewer(), ITextOperationTarget.SELECT_ALL); action = new TextViewerAction(getViewer(), ITextOperationTarget.SELECT_ALL);
action.configureAction(ConsoleMessages.getString("BuildConsolePage.Select_&All@Ctrl+A_12"), //$NON-NLS-1$ action.configureAction(ConsoleMessages.getString("BuildConsolePage.Select_&All@Ctrl+A_12"), //$NON-NLS-1$

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.io.IOException; import java.io.IOException;
@ -146,7 +144,7 @@ public class BuildConsolePartitioner
public ITypedRegion[] computePartitioning(int offset, int length) { public ITypedRegion[] computePartitioning(int offset, int length) {
if (offset == 0 && length == fDocument.getLength()) { if (offset == 0 && length == fDocument.getLength()) {
return (ITypedRegion[])fPartitions.toArray(new ITypedRegion[fPartitions.size()]); return (ITypedRegion[])fPartitions.toArray(new ITypedRegion[fPartitions.size()]);
} else { }
int end = offset + length; int end = offset + length;
List list = new ArrayList(); List list = new ArrayList();
for (int i = 0; i < fPartitions.size(); i++) { for (int i = 0; i < fPartitions.size(); i++) {
@ -159,7 +157,6 @@ public class BuildConsolePartitioner
} }
return (ITypedRegion[])list.toArray(new ITypedRegion[list.size()]); return (ITypedRegion[])list.toArray(new ITypedRegion[list.size()]);
} }
}
/** /**
* @see org.eclipse.jface.text.IDocumentPartitioner#getPartition(int) * @see org.eclipse.jface.text.IDocumentPartitioner#getPartition(int)
@ -234,7 +231,8 @@ public class BuildConsolePartitioner
} }
} else { } else {
// modify parition offset // modify parition offset
newPartition = messageConsolePartition.createNewPartition(messageConsolePartition.getOffset()-overflow, messageConsolePartition.getLength()); newPartition = messageConsolePartition.createNewPartition(messageConsolePartition.getOffset()
- overflow, messageConsolePartition.getLength());
} }
if (newPartition != null) { if (newPartition != null) {
newParitions.add(newPartition); newParitions.add(newPartition);
@ -243,7 +241,6 @@ public class BuildConsolePartitioner
} }
fPartitions = newParitions; fPartitions = newParitions;
//called from GUI Thread (see startUpdaterThread()), no asyncExec needed.
try { try {
fDocument.replace(0, overflow, ""); //$NON-NLS-1$ fDocument.replace(0, overflow, ""); //$NON-NLS-1$
} catch (BadLocationException e) { } catch (BadLocationException e) {
@ -252,11 +249,9 @@ public class BuildConsolePartitioner
} }
} }
/** /**
* Adds a new colored input partition, combining with the previous * Adds a new colored input partition, combining with the previous partition
* partition if possible. * if possible.
*/ */
private BuildConsolePartition addPartition(BuildConsolePartition partition) { private BuildConsolePartition addPartition(BuildConsolePartition partition) {
if (fPartitions.isEmpty()) { if (fPartitions.isEmpty()) {
@ -310,7 +305,6 @@ public class BuildConsolePartitioner
flush(); flush();
} }
public synchronized void write(byte[] b, int off, int len) throws IOException { public synchronized void write(byte[] b, int off, int len) throws IOException {
super.write(b, off, len); super.write(b, off, len);
flush(); flush();