From c6795dde73c873a9bf77b4425adf63270c15af52 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Tue, 29 Oct 2013 19:01:18 +0100 Subject: [PATCH] In EditorConsole::write(), use all arguments When System.(out|err).print was used before there was a visible EditorConsole, the message was written to the stderr/stdout by this instead of the EditorConsole. However, the write(data, offset, length) version would not pass on its offset and length parameters to the stdout/stderr stream, causing (parts of) a message to be printed multiple times. This commit makes sure the parameters are all properly passed to the real stream. For some reason the write(int) and write(byte[], int, int) methods in PrintStream do not throw an IOException like the write(byte[]) version, so the try block has to go. --- app/src/processing/app/EditorConsole.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/src/processing/app/EditorConsole.java b/app/src/processing/app/EditorConsole.java index 786fd8a16..bfd20e152 100644 --- a/app/src/processing/app/EditorConsole.java +++ b/app/src/processing/app/EditorConsole.java @@ -333,13 +333,11 @@ public class EditorConsole extends JScrollPane { if (currentConsole != null) { currentConsole.write(b, offset, length, err); } else { - try { - if (err) { - systemErr.write(b); - } else { - systemOut.write(b); - } - } catch (IOException e) { } // just ignore, where would we write? + if (err) { + systemErr.write(b, offset, length); + } else { + systemOut.write(b, offset, length); + } } OutputStream echo = err ? stderrFile : stdoutFile;