add null check to sketch loading

This commit is contained in:
Ben Fry
2017-05-04 15:31:21 -04:00
parent 97ce4e66d6
commit 50cdb44081
2 changed files with 9 additions and 1 deletions
+7 -1
View File
@@ -283,6 +283,12 @@ public class SketchCode {
public void load() throws IOException {
program = Util.loadFile(file);
if (program == null) {
System.err.println("There was a problem loading " + file);
System.err.println("This may happen because you don't have permissions to read the file, or the file has gone missing.");
throw new IOException("Cannot read or access " + file);
}
// Remove NUL characters because they'll cause problems,
// and their presence is very difficult to debug.
// https://github.com/processing/processing/issues/1973
@@ -292,7 +298,7 @@ public class SketchCode {
savedProgram = program;
// This used to be the "Fix Encoding and Reload" warning, but since that
// tool has been removed, it just rambles about text editors and encodings.
// tool has been removed, let's ramble about text editors and encodings.
if (program.indexOf('\uFFFD') != -1) {
System.err.println(file.getName() + " contains unrecognized characters.");
System.err.println("You should re-open " + file.getName() +
+2
View File
@@ -14,6 +14,8 @@ X 'run sketches on display' message shows up on clean install
X should ant run launch the .app so that launchsvcs stuff works properly?
X double-clicking a .pde file won't open the app correctly
X add 'ant app' target, at least for macOS
X add null check to sketch loading
X discovered during https://github.com/processing/processing/issues/4980
gohai
X IO library updates