Skip to content

Commit bf99ae2

Browse files
committed
fighting more battles for #3543
1 parent 76fef4b commit bf99ae2

File tree

4 files changed

+43
-27
lines changed

4 files changed

+43
-27
lines changed

app/src/processing/app/Base.java

100644100755
File mode changed.

app/src/processing/app/Util.java

100644100755
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,4 +666,12 @@ static public byte[] gzipEncode(byte[] what) throws IOException {
666666
output.close();
667667
return baos.toByteArray();
668668
}
669+
670+
671+
static public final boolean hasNonAsciiChars(String what) {
672+
for (char c : what.toCharArray()) {
673+
if (c < 32 || c > 127) return true;
674+
}
675+
return false;
676+
}
669677
}

app/src/processing/app/platform/WindowsPlatform.java

100644100755
Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import processing.app.Base;
3535
import processing.app.Messages;
3636
import processing.app.Preferences;
37+
import processing.app.Util;
3738
import processing.app.platform.WindowsRegistry.REGISTRY_ROOT_KEY;
3839

3940
import processing.core.PApplet;
@@ -255,29 +256,43 @@ protected void checkPath() {
255256

256257
// looking for Documents and Settings/blah/Application Data/Processing
257258
public File getSettingsFolder() throws Exception {
258-
String appDataRoaming = getAppDataPath();
259-
if (appDataRoaming != null) {
260-
File settingsFolder = new File(appDataRoaming, APP_NAME);
261-
if (settingsFolder.exists() || settingsFolder.mkdirs()) {
262-
return settingsFolder;
259+
try {
260+
String appDataRoaming = getAppDataPath();
261+
if (appDataRoaming != null) {
262+
File settingsFolder = new File(appDataRoaming, APP_NAME);
263+
if (settingsFolder.exists() || settingsFolder.mkdirs()) {
264+
return settingsFolder;
265+
}
266+
}
267+
268+
String appDataLocal = getLocalAppDataPath();
269+
if (appDataLocal != null) {
270+
File settingsFolder = new File(appDataLocal, APP_NAME);
271+
if (settingsFolder.exists() || settingsFolder.mkdirs()) {
272+
return settingsFolder;
273+
}
263274
}
264-
}
265275

266-
String appDataLocal = getLocalAppDataPath();
267-
if (appDataLocal != null) {
268-
File settingsFolder = new File(appDataLocal, APP_NAME);
269-
if (settingsFolder.exists() || settingsFolder.mkdirs()) {
270-
return settingsFolder;
276+
if (appDataRoaming == null && appDataLocal == null) {
277+
throw new IOException("Could not get the AppData folder");
271278
}
272-
}
273279

274-
if (appDataRoaming == null && appDataLocal == null) {
275-
throw new IOException("Could not get the AppData folder");
280+
// https://github.com/processing/processing/issues/3838
281+
throw new IOException("Permissions error: make sure that " +
282+
appDataRoaming + " or " + appDataLocal +
283+
" is writable.");
284+
285+
} catch (UnsatisfiedLinkError ule) {
286+
String path = new File("lib").getCanonicalPath();
287+
288+
String msg = Util.hasNonAsciiChars(path) ?
289+
"Please move Processing to a location with only\n" +
290+
"ASCII characters in the path and try again.\n" +
291+
"https://github.com/processing/processing/issues/3543" :
292+
"Could not find JNA support files, please reinstall Processing.";
293+
Messages.showError("Windows JNA Problem", msg, ule);
294+
return null; // unreachable
276295
}
277-
278-
// https://github.com/processing/processing/issues/3838
279-
throw new IOException("Please fix permissions for either " +
280-
appDataRoaming + " or " + appDataLocal);
281296
}
282297

283298

app/src/processing/app/ui/Toolkit.java

100644100755
Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
import processing.app.Messages;
7373
import processing.app.Platform;
7474
import processing.app.Preferences;
75+
import processing.app.Util;
7576

7677

7778
/**
@@ -990,7 +991,7 @@ static private Font createFont(String filename, int size) throws IOException, Fo
990991
// This gets the JAVA_HOME for the *local* copy of the JRE installed with
991992
// Processing. If it's not using the local JRE, it may be because of this
992993
// launch4j bug: https://github.com/processing/processing/issues/3543
993-
if (hasNonAsciiChars(Platform.getJavaHome().getAbsolutePath())) {
994+
if (Util.hasNonAsciiChars(Platform.getJavaHome().getAbsolutePath())) {
994995
msg += "Trying moving Processing\n" +
995996
"to a location with only ASCII characters in the path.";
996997
} else {
@@ -1006,14 +1007,6 @@ static private Font createFont(String filename, int size) throws IOException, Fo
10061007
}
10071008

10081009

1009-
static private final boolean hasNonAsciiChars(String what) {
1010-
for (char c : what.toCharArray()) {
1011-
if (c < 32 || c > 127) return true;
1012-
}
1013-
return false;
1014-
}
1015-
1016-
10171010
/**
10181011
* Synthesized replacement for FontMetrics.getAscent(), which is dreadfully
10191012
* inaccurate and inconsistent across platforms.

0 commit comments

Comments
 (0)