diff --git a/app/Base.java b/app/Base.java index 6d193c591..606c32005 100644 --- a/app/Base.java +++ b/app/Base.java @@ -250,7 +250,7 @@ public class Base { "Software\\Microsoft\\Windows\\CurrentVersion" + "\\Explorer\\Shell Folders"; RegistryKey localKey = topKey.openSubKey(localKeyPath); - String appDataPath = localKey.getStringValue("AppData"); + String appDataPath = cleanKey(localKey.getStringValue("AppData")); //System.out.println("app data path is " + appDataPath); //System.exit(0); //topKey.closeKey(); // necessary? @@ -278,6 +278,7 @@ public class Base { if (!result) { // try the fallback location + System.out.println("Using fallback path for settings."); String fallback = Preferences.get("settings.path.fallback"); dataFolder = new File(fallback); if (!dataFolder.exists()) { @@ -378,10 +379,9 @@ public class Base { "Software\\Microsoft\\Windows\\CurrentVersion" + "\\Explorer\\Shell Folders"; RegistryKey localKey = topKey.openSubKey(localKeyPath); - String personalPath = localKey.getStringValue("Personal"); + String personalPath = cleanKey(localKey.getStringValue("Personal")); //topKey.closeKey(); // necessary? //localKey.closeKey(); - sketchbookFolder = new File(personalPath, "Processing"); } catch (Exception e) { @@ -416,6 +416,7 @@ public class Base { if (!result) { // try the fallback location + System.out.println("Using fallback path for sketchbook."); String fallback = Preferences.get("sketchbook.path.fallback"); sketchbookFolder = new File(fallback); if (!sketchbookFolder.exists()) { @@ -433,6 +434,34 @@ public class Base { } + static public String cleanKey(String what) { + // jnireg seems to be reading the chars as bytes + // so maybe be as simple as & 0xff and then running through decoder + + char c[] = what.toCharArray(); + + // if chars are in the tooHigh range, it's prolly because + // a byte from the jni registry was turned into a char + // and there was a sign extension. + // e.g. 0xFC (252, umlaut u) became 0xFFFC (65532). + // but on a japanese system, maybe this is two-byte and ok? + int tooHigh = 65536 - 128; + for (int i = 0; i < c.length; i++) { + if (c[i] >= tooHigh) c[i] &= 0xff; + + /* + if ((c[i] >= 32) && (c[i] < 128)) { + System.out.print(c[i]); + } else { + System.out.print("[" + PApplet.hex(c[i]) + "]"); + } + */ + } + //System.out.println(); + return new String(c); + } + + // ................................................................. diff --git a/app/Compiler.java b/app/Compiler.java index f3c347359..51b5523fb 100644 --- a/app/Compiler.java +++ b/app/Compiler.java @@ -124,7 +124,7 @@ public class Compiler implements MessageConsumer { command[baseCommand.length + i] = buildPath + File.separator + preprocNames[i]; } - //PApplet.printarr(command); + //PApplet.println(command); /* String command[] = new String[baseCommand.length + sketch.codeCount]; diff --git a/app/Editor.java b/app/Editor.java index 0813d191e..0a4aca2cf 100644 --- a/app/Editor.java +++ b/app/Editor.java @@ -304,7 +304,7 @@ public class Editor extends JFrame windowW, windowH); // this will be invalid as well, so grab the new value Preferences.setInteger("last.divider.location", - splitPane.getDividerLocation()); + splitPane.getDividerLocation()); } else { setBounds(Preferences.getInteger("last.window.x"), Preferences.getInteger("last.window.y"), diff --git a/app/Sketchbook.java b/app/Sketchbook.java index 4d24a435d..d8a7102c7 100644 --- a/app/Sketchbook.java +++ b/app/Sketchbook.java @@ -89,9 +89,23 @@ public class Sketchbook { librariesFolder = new File(System.getProperty("user.dir"), "libraries"); librariesPath = librariesFolder.getAbsolutePath(); - //String sketchbookPath = Preferences.get("sketchbook.path"); - //if (sketchbookPath == null) { - if (Preferences.get("sketchbook.path") == null) { + String sketchbookPath = Preferences.get("sketchbook.path"); + + // if a value is at least set, first check to see if the + // folder exists. if it doesn't, warn the user that the + // sketchbook folder is being reset. + if (sketchbookPath != null) { + File skechbookFolder = new File(sketchbookPath); + if (!skechbookFolder.exists()) { + Base.showWarning("Sketchbook folder disappeared", + "The sketchbook folder no longer exists,\n" + + "so a new sketchbook will be created in the\n" + + "default location.", null); + sketchbookPath = null; + } + } + + if (sketchbookPath == null) { // by default, set default sketchbook path to the user's // home folder with 'sketchbook' as a subdirectory of that @@ -113,9 +127,10 @@ public class Sketchbook { //String folderName = Preferences.get("sketchbook.name.default"); //File sketchbookFolder = new File(home, folderName); + //System.out.println("resetting sketchbook path"); File sketchbookFolder = Base.getDefaultSketchbookFolder(); Preferences.set("sketchbook.path", - sketchbookFolder.getAbsolutePath()); + sketchbookFolder.getAbsolutePath()); if (!sketchbookFolder.exists()) sketchbookFolder.mkdirs(); } diff --git a/build/windows/launcher/processing.exe b/build/windows/launcher/processing.exe index affc1ffbd..25305385c 100755 Binary files a/build/windows/launcher/processing.exe and b/build/windows/launcher/processing.exe differ diff --git a/todo.txt b/todo.txt index 364683ee8..c35954812 100644 --- a/todo.txt +++ b/todo.txt @@ -22,7 +22,9 @@ _ from use in sketches, because users will rarely have the same font _ if sketchbook folder doesn't exist, default to the old folder _ people remove their old p5 folder which contained their sketchbook _ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Syntax;action=display;num=1116080833;start=0 -_ why would garbage in an app's "data" folder cause it to be read as a library? +_ don't allow subfolders inside the sketchbook folder +_ once a sketch is found, don't recurse deeper +_ same for libraries, cuz this makes a mess fixed previously o runtime exceptions have stopped coming through (on pc only?) @@ -122,6 +124,7 @@ PDE - Processing Development Environment PDE / Base _ settings.path.fallback not being used +_ need to check the mkdirs() to make sure it's not going too deep _ really important for intl versions that are having trouble _ or ask for the sketch folder name.. why isn't it? _ http://processing.org/bugs/show_bug.cgi?id=1