fighting more battles for #3543

This commit is contained in:
Ben Fry
2016-05-08 20:05:02 -04:00
parent 676d2531ec
commit 610ecd1d7a
4 changed files with 43 additions and 27 deletions
Regular → Executable
View File
Regular → Executable
+8
View File
@@ -666,4 +666,12 @@ public class Util {
output.close();
return baos.toByteArray();
}
static public final boolean hasNonAsciiChars(String what) {
for (char c : what.toCharArray()) {
if (c < 32 || c > 127) return true;
}
return false;
}
}
+33 -18
View File
@@ -34,6 +34,7 @@ import com.sun.jna.platform.win32.ShlObj;
import processing.app.Base;
import processing.app.Messages;
import processing.app.Preferences;
import processing.app.Util;
import processing.app.platform.WindowsRegistry.REGISTRY_ROOT_KEY;
import processing.core.PApplet;
@@ -255,29 +256,43 @@ public class WindowsPlatform extends DefaultPlatform {
// looking for Documents and Settings/blah/Application Data/Processing
public File getSettingsFolder() throws Exception {
String appDataRoaming = getAppDataPath();
if (appDataRoaming != null) {
File settingsFolder = new File(appDataRoaming, APP_NAME);
if (settingsFolder.exists() || settingsFolder.mkdirs()) {
return settingsFolder;
try {
String appDataRoaming = getAppDataPath();
if (appDataRoaming != null) {
File settingsFolder = new File(appDataRoaming, APP_NAME);
if (settingsFolder.exists() || settingsFolder.mkdirs()) {
return settingsFolder;
}
}
}
String appDataLocal = getLocalAppDataPath();
if (appDataLocal != null) {
File settingsFolder = new File(appDataLocal, APP_NAME);
if (settingsFolder.exists() || settingsFolder.mkdirs()) {
return settingsFolder;
String appDataLocal = getLocalAppDataPath();
if (appDataLocal != null) {
File settingsFolder = new File(appDataLocal, APP_NAME);
if (settingsFolder.exists() || settingsFolder.mkdirs()) {
return settingsFolder;
}
}
}
if (appDataRoaming == null && appDataLocal == null) {
throw new IOException("Could not get the AppData folder");
}
if (appDataRoaming == null && appDataLocal == null) {
throw new IOException("Could not get the AppData folder");
}
// https://github.com/processing/processing/issues/3838
throw new IOException("Please fix permissions for either " +
appDataRoaming + " or " + appDataLocal);
// https://github.com/processing/processing/issues/3838
throw new IOException("Permissions error: make sure that " +
appDataRoaming + " or " + appDataLocal +
" is writable.");
} catch (UnsatisfiedLinkError ule) {
String path = new File("lib").getCanonicalPath();
String msg = Util.hasNonAsciiChars(path) ?
"Please move Processing to a location with only\n" +
"ASCII characters in the path and try again.\n" +
"https://github.com/processing/processing/issues/3543" :
"Could not find JNA support files, please reinstall Processing.";
Messages.showError("Windows JNA Problem", msg, ule);
return null; // unreachable
}
}
+2 -9
View File
@@ -72,6 +72,7 @@ import processing.app.Language;
import processing.app.Messages;
import processing.app.Platform;
import processing.app.Preferences;
import processing.app.Util;
/**
@@ -990,7 +991,7 @@ public class Toolkit {
// This gets the JAVA_HOME for the *local* copy of the JRE installed with
// Processing. If it's not using the local JRE, it may be because of this
// launch4j bug: https://github.com/processing/processing/issues/3543
if (hasNonAsciiChars(Platform.getJavaHome().getAbsolutePath())) {
if (Util.hasNonAsciiChars(Platform.getJavaHome().getAbsolutePath())) {
msg += "Trying moving Processing\n" +
"to a location with only ASCII characters in the path.";
} else {
@@ -1006,14 +1007,6 @@ public class Toolkit {
}
static private final boolean hasNonAsciiChars(String what) {
for (char c : what.toCharArray()) {
if (c < 32 || c > 127) return true;
}
return false;
}
/**
* Synthesized replacement for FontMetrics.getAscent(), which is dreadfully
* inaccurate and inconsistent across platforms.