GeezerVison is showing github.com — Merge pull request #5486 from JakubValtar/fix-status-exception · crazyrex/processing@108f5cc
File tree
Expand file treeCollapse file tree
Open diff view settings
java/src/processing/mode/java
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboard +48Lines changed: 48 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +package processing.app; |
| 2 | + |
| 3 | +import java.awt.EventQueue; |
| 4 | + |
| 5 | +public class RunnerListenerEdtAdapter implements RunnerListener { |
| 6 | + |
| 7 | + private RunnerListener wrapped; |
| 8 | + |
| 9 | + public RunnerListenerEdtAdapter(RunnerListener wrapped) { |
| 10 | + this.wrapped = wrapped; |
| 11 | + } |
| 12 | + |
| 13 | + @Override |
| 14 | + public void statusError(String message) { |
| 15 | + EventQueue.invokeLater(() -> wrapped.statusError(message)); |
| 16 | + } |
| 17 | + |
| 18 | + @Override |
| 19 | + public void statusError(Exception exception) { |
| 20 | + EventQueue.invokeLater(() -> wrapped.statusError(exception)); |
| 21 | + } |
| 22 | + |
| 23 | + @Override |
| 24 | + public void statusNotice(String message) { |
| 25 | + EventQueue.invokeLater(() -> wrapped.statusNotice(message)); |
| 26 | + } |
| 27 | + |
| 28 | + @Override |
| 29 | + public void startIndeterminate() { |
| 30 | + EventQueue.invokeLater(() -> wrapped.startIndeterminate()); |
| 31 | + } |
| 32 | + |
| 33 | + @Override |
| 34 | + public void stopIndeterminate() { |
| 35 | + EventQueue.invokeLater(() -> wrapped.stopIndeterminate()); |
| 36 | + } |
| 37 | + |
| 38 | + @Override |
| 39 | + public void statusHalt() { |
| 40 | + EventQueue.invokeLater(() -> wrapped.statusHalt()); |
| 41 | + } |
| 42 | + |
| 43 | + @Override |
| 44 | + public boolean isHalted() { |
| 45 | + return wrapped.isHalted(); |
| 46 | + } |
| 47 | +} |
| 48 | + |
Collapse file
Copy file name to clipboardExpand all lines: app/src/processing/app/SketchException.java +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -130,6 +130,11 @@ public void hideStackTrace() { |
130 | 130 | } |
131 | 131 |
|
132 | 132 |
|
| 133 | + public boolean isStackTraceEnabled() { |
| 134 | + return showStackTrace; |
| 135 | + } |
| 136 | + |
| 137 | + |
133 | 138 | /** |
134 | 139 | * Nix the java.lang crap out of an exception message |
135 | 140 | * because it scares the children. |
|
Collapse file
Copy file name to clipboardExpand all lines: app/src/processing/app/ui/Editor.java +11Lines changed: 11 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2900,6 +2900,17 @@ public void statusError(Exception e) { |
2900 | 2900 |
|
2901 | 2901 | if (e instanceof SketchException) { |
2902 | 2902 | SketchException re = (SketchException) e; |
| 2903 | + |
| 2904 | + // Make sure something is printed into the console |
| 2905 | + // Status bar is volatile |
| 2906 | + if (!re.isStackTraceEnabled()) { |
| 2907 | + System.err.println(re.getMessage()); |
| 2908 | + } |
| 2909 | + |
| 2910 | + // Move the cursor to the line before updating the status bar, otherwise |
| 2911 | + // status message might get hidden by a potential message caused by moving |
| 2912 | + // the cursor to a line with warning in it |
| 2913 | + |
2903 | 2914 | if (re.hasCodeIndex()) { |
2904 | 2915 | sketch.setCurrentCode(re.getCodeIndex()); |
2905 | 2916 | } |
|
Collapse file
Copy file name to clipboardExpand all lines: java/src/processing/mode/java/Debugger.java +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
|
39 | 39 | import javax.swing.tree.DefaultMutableTreeNode; |
40 | 40 |
|
41 | 41 | import processing.app.Messages; |
| 42 | +import processing.app.RunnerListenerEdtAdapter; |
42 | 43 | import processing.app.Sketch; |
43 | 44 | import processing.app.SketchCode; |
44 | 45 | import processing.mode.java.debug.*; |
@@ -201,7 +202,7 @@ public synchronized void startDebug() { |
201 | 202 | //lineMap = LineMapping.generateMapping(srcPath + File.separator + mainClassName + ".java"); |
202 | 203 |
|
203 | 204 | log("launching debuggee runtime"); |
204 | | - runtime = new Runner(build, editor); |
| 205 | + runtime = new Runner(build, new RunnerListenerEdtAdapter(editor)); |
205 | 206 | VirtualMachine vm = runtime.debug(null); // non-blocking |
206 | 207 | if (vm == null) { |
207 | 208 | loge("error 37: launch failed", null); |
|
Collapse file
Copy file name to clipboardExpand all lines: java/src/processing/mode/java/JavaEditor.java +3-2Lines changed: 3 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1094,10 +1094,11 @@ protected void handleLaunch(boolean present, boolean tweak) { |
1094 | 1094 | synchronized (runtimeLock) { |
1095 | 1095 | if (runtimeLaunchRequested) { |
1096 | 1096 | runtimeLaunchRequested = false; |
| 1097 | + RunnerListener listener = new RunnerListenerEdtAdapter(JavaEditor.this); |
1097 | 1098 | if (!tweak) { |
1098 | | - runtime = jmode.handleLaunch(sketch, JavaEditor.this, present); |
| 1099 | + runtime = jmode.handleLaunch(sketch, listener, present); |
1099 | 1100 | } else { |
1100 | | - runtime = jmode.handleTweak(sketch, JavaEditor.this); |
| 1101 | + runtime = jmode.handleTweak(sketch, listener); |
1101 | 1102 | } |
1102 | 1103 | } |
1103 | 1104 | } |
|