diff options
author | Darin Wright | 2009-03-26 18:35:29 +0000 |
---|---|---|
committer | Darin Wright | 2009-03-26 18:35:29 +0000 |
commit | 51cc366c0c2fb599161c261e84a6d06fb5ac3ab4 (patch) | |
tree | fce7e5413e24cda8fa266d93c75fb2acd942e7be | |
parent | 016e5e2a0cc53d6a8ee4f09827dca6528936a1fc (diff) | |
download | eclipse.platform.debug-R3_3_maintenance.tar.gz eclipse.platform.debug-R3_3_maintenance.tar.xz eclipse.platform.debug-R3_3_maintenance.zip |
[r33x] Bug 259107 - [console] Console Deadlock when too much information writtenR3_3_maintenance
-rw-r--r-- | org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java | 113 |
1 files changed, 65 insertions, 48 deletions
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 10e7744ef..3603fb27b 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. + * Copyright (c) 2000, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -29,6 +29,7 @@ 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; @@ -461,11 +462,19 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum } } - if (fBuffer > 160000) { - try { - pendingPartitions.wait(); - } catch (InterruptedException e) { - } + if (fBuffer > 160000) { + if(Display.getCurrent() == null){ + try { + pendingPartitions.wait(); + } catch (InterruptedException e) { + } + } else { + /* + * if we are in UI thread we cannot lock it, so process + * queued output. + */ + processQueue(); + } } } } @@ -505,47 +514,7 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum * @see org.eclipse.core.internal.jobs.InternalJob#run(org.eclipse.core.runtime.IProgressMonitor) */ 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(); - } - - 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(); - - } - + processQueue(); return Status.OK_STATUS; } @@ -563,7 +532,55 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum } - + void processQueue() { + 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(); + } + // determine buffer size + int size = 0; + for (Iterator i = pendingCopy.iterator(); i.hasNext(); ) { + PendingPartition pp = (PendingPartition) i.next(); + if (pp != consoleClosedPartition) { + size+= pp.text.length(); + } + } + buffer = new StringBuffer(size); + 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(); + } + + } |