Skip to content

Commit 832cc07

Browse files
committed
swtich to a lambda (fixes bad indent), and redo version reading code
1 parent b072e3a commit 832cc07

File tree

1 file changed

+34
-38
lines changed

1 file changed

+34
-38
lines changed

app/src/processing/app/Base.java

Lines changed: 34 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -107,53 +107,49 @@ public class Base {
107107

108108

109109
static public void main(final String[] args) {
110-
EventQueue.invokeLater(new Runnable() {
111-
public void run() {
112-
try {
113-
createAndShowGUI(args);
114-
115-
} catch (Throwable t) {
116-
// Windows Defender has been insisting on destroying each new
117-
// release by removing core.jar and other files. Yay!
118-
// https://github.com/processing/processing/issues/5537
119-
if (Platform.isWindows()) {
120-
String mess = t.getMessage();
121-
String missing = null;
122-
if (mess.contains("Could not initialize class com.sun.jna.Native")) {
123-
missing = "jnidispatch.dll";
124-
} else if (mess.contains("NoClassDefFoundError: processing/core/PApplet")) {
125-
missing = "core.jar";
126-
}
127-
if (missing != null) {
128-
Messages.showError("Necessary files are missing",
129-
"A file required by Processing (" + missing + ") is missing.\n\n" +
130-
"Make sure that you're not trying to run Processing from inside\n" +
131-
"the .zip file you downloaded, and check that Windows Defender\n" +
132-
"hasn't removed files from the Processing folder.\n\n" +
133-
"(It sometimes flags parts of Processing as a trojan or virus.\n" +
134-
"It is neither, but Microsoft has ignored our pleas for help.)", t);
135-
}
136-
}
137-
Messages.showTrace("Unknown Problem",
138-
"A serious error happened during startup. Please report:\n" +
139-
"http://github.com/processing/processing/issues/new", t, true);
110+
EventQueue.invokeLater(() -> {
111+
try {
112+
createAndShowGUI(args);
113+
114+
} catch (Throwable t) {
115+
// Windows Defender has been insisting on destroying each new
116+
// release by removing core.jar and other files. Yay!
117+
// https://github.com/processing/processing/issues/5537
118+
if (Platform.isWindows()) {
119+
String mess = t.getMessage();
120+
String missing = null;
121+
if (mess.contains("Could not initialize class com.sun.jna.Native")) {
122+
missing = "jnidispatch.dll";
123+
} else if (mess.contains("NoClassDefFoundError: processing/core/PApplet")) {
124+
missing = "core.jar";
125+
}
126+
if (missing != null) {
127+
Messages.showError("Necessary files are missing",
128+
"A file required by Processing (" + missing + ") is missing.\n\n" +
129+
"Make sure that you're not trying to run Processing from inside\n" +
130+
"the .zip file you downloaded, and check that Windows Defender\n" +
131+
"hasn't removed files from the Processing folder.\n\n" +
132+
"(It sometimes flags parts of Processing as a trojan or virus.\n" +
133+
"It is neither, but Microsoft has ignored our pleas for help.)", t);
140134
}
141135
}
136+
Messages.showTrace("Unknown Problem",
137+
"A serious error happened during startup. Please report:\n" +
138+
"http://github.com/processing/processing/issues/new", t, true);
139+
}
142140
});
143141
}
144142

145143

146144
static private void createAndShowGUI(String[] args) {
147-
try {
148-
File versionFile = Platform.getContentFile("lib/version.txt");
149-
if (versionFile.exists()) {
150-
String version = PApplet.loadStrings(versionFile)[0];
151-
if (!version.equals(VERSION_NAME)) {
152-
VERSION_NAME = version;
145+
File versionFile = Platform.getContentFile("lib/version.txt");
146+
if (versionFile != null && versionFile.exists()) {
147+
String[] lines = PApplet.loadStrings(versionFile);
148+
if (lines != null && lines.length > 0) {
149+
if (!VERSION_NAME.equals(lines[0])) {
150+
VERSION_NAME = lines[0];
153151
}
154152
}
155-
} catch (Exception e) {
156-
e.printStackTrace();
157153
}
158154

159155
Platform.init();

0 commit comments

Comments
 (0)