Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Barnes2006-03-08 15:57:35 -0500
committerKevin Barnes2006-03-08 15:57:35 -0500
commit0f87f4c2019a70933be145eb375c7fbf429a91ad (patch)
tree754ce9172188dd6e3cae632c097e20f7081428d5 /org.eclipse.ui.console
parent09fe4d4c406ae3f7abf79e16d44cb82b799d99f0 (diff)
downloadeclipse.platform.debug-0f87f4c2019a70933be145eb375c7fbf429a91ad.tar.gz
eclipse.platform.debug-0f87f4c2019a70933be145eb375c7fbf429a91ad.tar.xz
eclipse.platform.debug-0f87f4c2019a70933be145eb375c7fbf429a91ad.zip
Bug 130431 - A lot of characters in a line of output crashes Eclipse
Diffstat (limited to 'org.eclipse.ui.console')
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleDocumentAdapter.java2
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleManager.java99
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java99
3 files changed, 104 insertions, 96 deletions
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleDocumentAdapter.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleDocumentAdapter.java
index f42c147c0..104f29160 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleDocumentAdapter.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleDocumentAdapter.java
@@ -45,7 +45,7 @@ public class ConsoleDocumentAdapter implements IDocumentAdapter, IDocumentListen
int[] lengths = new int[5000];
private int regionCount = 0;
- private Pattern pattern = Pattern.compile("^.*$", Pattern.MULTILINE); //$NON-NLS-1$
+ private Pattern pattern = Pattern.compile("^", Pattern.MULTILINE); //$NON-NLS-1$
public ConsoleDocumentAdapter(int width) {
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleManager.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleManager.java
index 8582c9dba..76a266947 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleManager.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleManager.java
@@ -26,6 +26,7 @@ import org.eclipse.core.runtime.ListenerList;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPage;
@@ -263,50 +264,68 @@ public class ConsoleManager implements IConsoleManager {
new ConsoleNotifier().notify(consoles, type);
}
+
+ private class ShowConsoleViewJob extends WorkbenchJob {
+ private IConsole console;
+
+ ShowConsoleViewJob() {
+ super("Show Console View"); //$NON-NLS-1$
+ setSystem(true);
+ setPriority(Job.SHORT);
+ }
+
+ void setConsole(IConsole console) {
+ this.console = console;
+ }
+
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ boolean consoleFound = false;
+ IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window != null) {
+ IWorkbenchPage page= window.getActivePage();
+ if (page != null) {
+ synchronized (fConsoleViews) {
+ for (Iterator iter = fConsoleViews.iterator(); iter.hasNext();) {
+ ConsoleView consoleView = (ConsoleView) iter.next();
+ boolean consoleVisible = page.isPartVisible(consoleView);
+ if (consoleVisible) {
+ consoleFound = true;
+
+ boolean bringToTop = shouldBringToTop(console, consoleView);
+ if (bringToTop) {
+ page.bringToTop(consoleView);
+ }
+
+ consoleView.display(console);
+ }
+ }
+ }
+
+ if (!consoleFound) {
+ try {
+ IConsoleView consoleView = (IConsoleView) page.showView(IConsoleConstants.ID_CONSOLE_VIEW, null, IWorkbenchPage.VIEW_CREATE);
+ boolean bringToTop = shouldBringToTop(console, consoleView);
+ if (bringToTop) {
+ page.bringToTop(consoleView);
+ }
+ consoleView.display(console);
+ } catch (PartInitException pie) {
+ ConsolePlugin.log(pie);
+ }
+ }
+ }
+ }
+ return Status.OK_STATUS;
+ }
+ }
+
+ private ShowConsoleViewJob showJob = new ShowConsoleViewJob();
/**
* @see IConsoleManager#showConsoleView(IConsole)
*/
public void showConsoleView(final IConsole console) {
- ConsolePlugin.getStandardDisplay().asyncExec(new Runnable() {
- public void run() {
- boolean consoleFound = false;
- IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window != null) {
- IWorkbenchPage page= window.getActivePage();
- if (page != null) {
- synchronized (fConsoleViews) {
- for (Iterator iter = fConsoleViews.iterator(); iter.hasNext();) {
- ConsoleView consoleView = (ConsoleView) iter.next();
- boolean consoleVisible = page.isPartVisible(consoleView);
- if (consoleVisible) {
- consoleFound = true;
-
- boolean bringToTop = shouldBringToTop(console, consoleView);
- if (bringToTop) {
- page.bringToTop(consoleView);
- }
-
- consoleView.display(console);
- }
- }
- }
-
- if (!consoleFound) {
- try {
- IConsoleView consoleView = (IConsoleView) page.showView(IConsoleConstants.ID_CONSOLE_VIEW, null, IWorkbenchPage.VIEW_CREATE);
- boolean bringToTop = shouldBringToTop(console, consoleView);
- if (bringToTop) {
- page.bringToTop(consoleView);
- }
- consoleView.display(console);
- } catch (PartInitException pie) {
- ConsolePlugin.log(pie);
- }
- }
- }
- }
- }
- });
+ showJob.setConsole(console);
+ showJob.schedule(100);
}
/**
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java
index 54415d5f9..2d2867c0c 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java
@@ -30,7 +30,6 @@ import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITypedRegion;
import org.eclipse.jface.text.Region;
import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.console.ConsolePlugin;
import org.eclipse.ui.console.IConsoleDocumentPartitioner;
import org.eclipse.ui.console.IOConsole;
@@ -495,7 +494,7 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum
* Updates the document. Will append everything that is available before
* finishing.
*/
- private class QueueProcessingJob extends Job {
+ private class QueueProcessingJob extends WorkbenchJob {
QueueProcessingJob() {
super("IOConsole Updater"); //$NON-NLS-1$
@@ -505,60 +504,50 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum
* (non-Javadoc)
* @see org.eclipse.core.internal.jobs.InternalJob#run(org.eclipse.core.runtime.IProgressMonitor)
*/
- protected IStatus run(IProgressMonitor monitor) {
- synchronized (overflowLock) {
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ synchronized (overflowLock) {
+ ArrayList pendingCopy = new ArrayList();
+ StringBuffer buffer = null;
+ boolean consoleClosed = false;
+ while (pendingPartitions.size() > 0) {
+ synchronized(pendingPartitions) {
+ pendingCopy.addAll(pendingPartitions);
+ pendingPartitions.clear();
+ fBuffer = 0;
+ pendingPartitions.notifyAll();
+ }
- Display display = ConsolePlugin.getStandardDisplay();
-
- ArrayList pendingCopy = new ArrayList();
- StringBuffer buffer = null;
- boolean consoleClosed = false;
- while (pendingPartitions.size() > 0) {
- synchronized(pendingPartitions) {
- pendingCopy.addAll(pendingPartitions);
- pendingPartitions.clear();
- fBuffer = 0;
- pendingPartitions.notifyAll();
- }
-
- buffer = new StringBuffer();
- for (Iterator i = pendingCopy.iterator(); i.hasNext(); ) {
- PendingPartition pp = (PendingPartition) i.next();
- if (pp != consoleClosedPartition) {
- buffer.append(pp.text);
- } else {
- consoleClosed = true;
- }
- }
- }
-
- final ArrayList finalCopy = pendingCopy;
- final String toAppend = buffer.toString();
- final boolean notifyClosed = consoleClosed;
-
- display.asyncExec(new Runnable() {
- public void run() {
- if (connected) {
- setUpdateInProgress(true);
- updatePartitions = finalCopy;
- firstOffset = document.getLength();
- try {
- document.replace(firstOffset, 0, toAppend.toString());
- } catch (BadLocationException e) {
- }
- updatePartitions = null;
- setUpdateInProgress(false);
- }
- if (notifyClosed) {
- console.partitionerFinished();
- }
- checkBufferSize();
- }
- });
- }
-
- return Status.OK_STATUS;
- }
+ buffer = new StringBuffer();
+ for (Iterator i = pendingCopy.iterator(); i.hasNext(); ) {
+ PendingPartition pp = (PendingPartition) i.next();
+ if (pp != consoleClosedPartition) {
+ buffer.append(pp.text);
+ } else {
+ consoleClosed = true;
+ }
+ }
+ }
+
+ if (connected) {
+ setUpdateInProgress(true);
+ updatePartitions = pendingCopy;
+ firstOffset = document.getLength();
+ try {
+ document.replace(firstOffset, 0, buffer.toString());
+ } catch (BadLocationException e) {
+ }
+ updatePartitions = null;
+ setUpdateInProgress(false);
+ }
+ if (consoleClosed) {
+ console.partitionerFinished();
+ }
+ checkBufferSize();
+
+ }
+
+ return Status.OK_STATUS;
+ }
/*
* Job will process as much as it can each time it's run, but it gets

Back to the top