mirror of
https://github.com/processing/processing4.git
synced 2026-02-03 05:39:18 +01:00
add additional error-checking and workarounds for #3624
This commit is contained in:
@@ -111,7 +111,7 @@ public class Base {
|
||||
try {
|
||||
createAndShowGUI(args);
|
||||
} catch (Throwable t) {
|
||||
Messages.showBadnessTrace("It was not meant to be",
|
||||
Messages.showTrace("It was not meant to be",
|
||||
"A serious problem happened during startup. Please report:\n" +
|
||||
"http://github.com/processing/processing/issues/new", t, true);
|
||||
}
|
||||
@@ -209,7 +209,7 @@ public class Base {
|
||||
try {
|
||||
new Welcome(base, prompt);
|
||||
} catch (IOException e) {
|
||||
Messages.showBadnessTrace("Unwelcoming",
|
||||
Messages.showTrace("Unwelcoming",
|
||||
"Please report this error to\n" +
|
||||
"https://github.com/processing/processing/issues", e, false);
|
||||
}
|
||||
@@ -224,7 +224,7 @@ public class Base {
|
||||
// show this one so that it's not truncated in the error window.
|
||||
t = t.getCause();
|
||||
}
|
||||
Messages.showBadnessTrace("We're off on the wrong foot",
|
||||
Messages.showTrace("We're off on the wrong foot",
|
||||
"An error occurred during startup.", t, true);
|
||||
}
|
||||
Messages.log("done creating base..."); //$NON-NLS-1$
|
||||
@@ -915,11 +915,11 @@ public class Base {
|
||||
"Try updating the Mode or contact its author for a new version.", nsme);
|
||||
} catch (Throwable t) {
|
||||
if (nextMode.equals(getDefaultMode())) {
|
||||
Messages.showBadnessTrace("Serious Problem",
|
||||
Messages.showTrace("Serious Problem",
|
||||
"An unexpected, unknown, and unrecoverable error occurred\n" +
|
||||
"while opening a new editor window. Please report this.", t, true);
|
||||
} else {
|
||||
Messages.showBadnessTrace("Mode Problems",
|
||||
Messages.showTrace("Mode Problems",
|
||||
"A nasty error occurred while trying to use " + nextMode.getTitle() + ".\n" +
|
||||
"It may not be compatible with this version of Processing.\n" +
|
||||
"Try updating the Mode or contact its author for a new version.", t, false);
|
||||
@@ -943,7 +943,7 @@ public class Base {
|
||||
*/
|
||||
|
||||
} catch (Throwable t) {
|
||||
Messages.showBadnessTrace("Terrible News",
|
||||
Messages.showTrace("Terrible News",
|
||||
"A serious error occurred while " +
|
||||
"trying to create a new editor window.", t,
|
||||
nextMode == getDefaultMode()); // quit if default
|
||||
|
||||
@@ -155,7 +155,7 @@ public class Messages {
|
||||
/**
|
||||
* Testing a new warning window that includes the stack trace.
|
||||
*/
|
||||
static void showBadnessTrace(String title, String message,
|
||||
static public void showTrace(String title, String message,
|
||||
Throwable t, boolean fatal) {
|
||||
if (title == null) title = fatal ? "Error" : "Warning";
|
||||
|
||||
|
||||
@@ -501,7 +501,46 @@ public class WindowsPlatform extends DefaultPlatform {
|
||||
// Code partially thanks to Richard Quirk from:
|
||||
// http://quirkygba.blogspot.com/2009/11/setting-environment-variables-in-java.html
|
||||
|
||||
static WinLibC clib = (WinLibC) Native.loadLibrary("msvcrt", WinLibC.class);
|
||||
static WinLibC clib;
|
||||
|
||||
|
||||
static WinLibC getLibC() {
|
||||
if (clib == null) {
|
||||
try {
|
||||
clib = (WinLibC) Native.loadLibrary("msvcrt", WinLibC.class);
|
||||
} catch (UnsatisfiedLinkError ule) {
|
||||
// Might be a problem with file encoding, use a default directory
|
||||
// https://github.com/processing/processing/issues/3624
|
||||
File ctmp = new File("C:\\TEMP"); // kick it old school
|
||||
if (ctmp.exists() || ctmp.mkdirs()) {
|
||||
try {
|
||||
File jnaTmp = File.createTempFile("processing", "jna", ctmp);
|
||||
if (jnaTmp.mkdirs()) {
|
||||
jnaTmp.deleteOnExit(); // clean up when we're done
|
||||
System.setProperty("jna.tmpdir", jnaTmp.getAbsolutePath());
|
||||
try {
|
||||
clib = (WinLibC) Native.loadLibrary("msvcrt", WinLibC.class);
|
||||
} catch (UnsatisfiedLinkError ulf) {
|
||||
Messages.showTrace("No luck with JNA",
|
||||
"After several attempts, JNA could not be loaded. Please report:\n" +
|
||||
"http://github.com/processing/processing/issues/new", ulf, true);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Messages.showTrace("Could not create temp directory",
|
||||
"JNA could not be loaded properly. Please report:\n" +
|
||||
"http://github.com/processing/processing/issues/new", e, true);
|
||||
}
|
||||
} else {
|
||||
Messages.showError("Could not create temp directory",
|
||||
"JNA could not be loaded into C:\\TEMP. Please report:\n" +
|
||||
"http://github.com/processing/processing/issues/new", null);
|
||||
}
|
||||
}
|
||||
}
|
||||
return clib;
|
||||
}
|
||||
|
||||
|
||||
public interface WinLibC extends Library {
|
||||
//WinLibC INSTANCE = (WinLibC) Native.loadLibrary("msvcrt", WinLibC.class);
|
||||
@@ -512,7 +551,7 @@ public class WindowsPlatform extends DefaultPlatform {
|
||||
|
||||
public void setenv(String variable, String value) {
|
||||
//WinLibC clib = WinLibC.INSTANCE;
|
||||
clib._putenv(variable + "=" + value);
|
||||
getLibC()._putenv(variable + "=" + value);
|
||||
}
|
||||
|
||||
|
||||
@@ -525,7 +564,7 @@ public class WindowsPlatform extends DefaultPlatform {
|
||||
//WinLibC clib = WinLibC.INSTANCE;
|
||||
//clib._putenv(variable + "=");
|
||||
//return 0;
|
||||
return clib._putenv(variable + "=");
|
||||
return getLibC()._putenv(variable + "=");
|
||||
}
|
||||
|
||||
|
||||
|
||||
5
todo.txt
5
todo.txt
@@ -11,8 +11,9 @@ X https://github.com/processing/processing/issues/707
|
||||
X https://github.com/processing/processing/pull/3660
|
||||
|
||||
gsoc
|
||||
_ Foundation libraries disapear from CM after restart
|
||||
_ https://github.com/processing/processing/issues/3659
|
||||
X Foundation libraries disapear from CM after restart
|
||||
X https://github.com/processing/processing/issues/3659
|
||||
X https://github.com/processing/processing/pull/3663
|
||||
|
||||
earlier
|
||||
X modify build to insert these after antlr run:
|
||||
|
||||
Reference in New Issue
Block a user