Skip to content

Commit a12fa6a

Browse files
authored
Merge pull request #2 from sampottinger/master
Sync to master processing while working on #5753 / #5750
2 parents f68fd9e + 46d25b9 commit a12fa6a

27 files changed

Lines changed: 817 additions & 253 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
*~
66
/build/shared/reference.zip
77

8+
# temporary, until we complete the move to IntelliJ
9+
*.iml
10+
/.idea
811

912
# via https://github.com/github/gitignore/blob/master/Global/JetBrains.gitignore
1013
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+

app/src/processing/app/Sketch.java

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ public class Sketch {
9191
/** Moved out of Editor and into here for cleaner access. */
9292
private boolean untitled;
9393

94+
/** true if we've posted a "sketch disappeared" warning */
95+
private boolean disappearedWarning;
9496

9597
/**
9698
* Used by the command-line version to create a sketch object.
@@ -123,6 +125,7 @@ protected void load(String path) {
123125
int suffixLength = mode.getDefaultExtension().length() + 1;
124126
name = mainFilename.substring(0, mainFilename.length() - suffixLength);
125127
folder = new File(new File(path).getParent());
128+
disappearedWarning = false;
126129
load();
127130
}
128131

@@ -1197,6 +1200,7 @@ protected void updateInternal(String sketchName, File sketchFolder) {
11971200

11981201
name = sketchName;
11991202
folder = sketchFolder;
1203+
disappearedWarning = false;
12001204
codeFolder = new File(folder, "code");
12011205
dataFolder = new File(folder, "data");
12021206

@@ -1498,28 +1502,34 @@ public void prepareBuild(File targetFolder) throws SketchException {
14981502

14991503

15001504
/**
1501-
* Make sure the sketch hasn't been moved or deleted by some
1502-
* nefarious user. If they did, try to re-create it and save.
1503-
* Only checks to see if the main folder is still around,
1504-
* but not its contents.
1505+
* Make sure the sketch hasn't been moved or deleted by a nefarious user.
1506+
* If they did, try to re-create it and save. Only checks whether the
1507+
* main folder is still around, but not its contents.
15051508
*/
15061509
public void ensureExistence() {
15071510
if (!folder.exists()) {
1508-
// Disaster recovery, try to salvage what's there already.
1509-
Messages.showWarning(Language.text("ensure_exist.messages.missing_sketch"),
1510-
Language.text("ensure_exist.messages.missing_sketch.description"));
1511-
try {
1512-
folder.mkdirs();
1513-
modified = true;
1511+
// Avoid an infinite loop if we've already warned about this
1512+
// https://github.com/processing/processing/issues/4805
1513+
if (!disappearedWarning) {
1514+
disappearedWarning = true;
1515+
1516+
// Disaster recovery, try to salvage what's there already.
1517+
Messages.showWarning(Language.text("ensure_exist.messages.missing_sketch"),
1518+
Language.text("ensure_exist.messages.missing_sketch.description"));
1519+
try {
1520+
folder.mkdirs();
1521+
modified = true;
1522+
1523+
for (int i = 0; i < codeCount; i++) {
1524+
code[i].save(); // this will force a save
1525+
}
1526+
calcModified();
15141527

1515-
for (int i = 0; i < codeCount; i++) {
1516-
code[i].save(); // this will force a save
1528+
} catch (Exception e) {
1529+
// disappearedWarning prevents infinite loop in this scenario
1530+
Messages.showWarning(Language.text("ensure_exist.messages.unrecoverable"),
1531+
Language.text("ensure_exist.messages.unrecoverable.description"), e);
15171532
}
1518-
calcModified();
1519-
1520-
} catch (Exception e) {
1521-
Messages.showWarning(Language.text("ensure_exist.messages.unrecoverable"),
1522-
Language.text("ensure_exist.messages.unrecoverable.description"), e);
15231533
}
15241534
}
15251535
}

app/src/processing/app/SketchException.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ public void hideStackTrace() {
130130
}
131131

132132

133+
public boolean isStackTraceEnabled() {
134+
return showStackTrace;
135+
}
136+
137+
133138
/**
134139
* Nix the java.lang crap out of an exception message
135140
* because it scares the children.

app/src/processing/app/ui/Editor.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,17 @@ public BasicSplitPaneDivider createDefaultDivider() {
320320
status = new EditorStatus(this, Editor.this);
321321
return status;
322322
}
323+
324+
325+
@Override
326+
public void finishDraggingTo(int location) {
327+
super.finishDraggingTo(location);
328+
// JSplitPane issue: if you only make the lower component visible at
329+
// the last minute, its minmum size is ignored.
330+
if (location > splitPane.getMaximumDividerLocation()) {
331+
splitPane.setDividerLocation(splitPane.getMaximumDividerLocation());
332+
}
333+
}
323334
});
324335

325336
box.add(splitPane);
@@ -2900,6 +2911,17 @@ public void statusError(Exception e) {
29002911

29012912
if (e instanceof SketchException) {
29022913
SketchException re = (SketchException) e;
2914+
2915+
// Make sure something is printed into the console
2916+
// Status bar is volatile
2917+
if (!re.isStackTraceEnabled()) {
2918+
System.err.println(re.getMessage());
2919+
}
2920+
2921+
// Move the cursor to the line before updating the status bar, otherwise
2922+
// status message might get hidden by a potential message caused by moving
2923+
// the cursor to a line with warning in it
2924+
29032925
if (re.hasCodeIndex()) {
29042926
sketch.setCurrentCode(re.getCodeIndex());
29052927
}

app/src/processing/app/ui/EditorConsole.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ public void message(String what, boolean err) {
233233
// https://github.com/processing/processing/issues/5462
234234
// Some discussion on the Apple's developer forums seems to suggest that is not serious:
235235
// https://forums.developer.apple.com/thread/105244
236+
} else if (err && what.contains("NSWindow drag regions should only be invalidated on the Main Thread")) {
237+
// Keep hiding warnings triggered by JOGL on recent macOS versions (this is from 10.14 onwards I think).
236238
} else if (err && what.contains("Make pbuffer:")) {
237239
// Remove initalization warning from LWJGL.
238240
} else if (err && what.contains("XInitThreads() called for concurrent")) {

0 commit comments

Comments
 (0)