Skip to content

Commit 991ae1c

Browse files
committed
improve error handling, to sort out settings folder issues on Windows 10 #3838
1 parent 11ec778 commit 991ae1c

File tree

2 files changed

+9
-30
lines changed

2 files changed

+9
-30
lines changed

app/src/processing/app/Base.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1733,7 +1733,8 @@ static public File getSettingsFolder() {
17331733
if (!settingsFolder.mkdirs()) {
17341734
Messages.showError("Settings issues",
17351735
"Processing cannot run because it could not\n" +
1736-
"create a folder to store your settings.", null);
1736+
"create a folder to store your settings.\n" +
1737+
settingsFolder.getAbsolutePath(), null);
17371738
}
17381739
}
17391740
return settingsFolder;

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

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -268,27 +268,6 @@ public File getSettingsFolder() throws Exception {
268268

269269

270270
static private String getAppDataPath() throws Exception {
271-
// Trying to deal with JNA problems on Windows 10
272-
// https://github.com/processing/processing/issues/3800
273-
// Try to load JNA and set its temporary directory
274-
getLibC();
275-
276-
// HKEY_CURRENT_USER\Software\Microsoft
277-
// \Windows\CurrentVersion\Explorer\Shell Folders
278-
// Value Name: AppData
279-
// Value Type: REG_SZ
280-
// Value Data: path
281-
282-
//String keyPath =
283-
// "Software\\Microsoft\\Windows\\CurrentVersion" +
284-
// "\\Explorer\\Shell Folders";
285-
//String appDataPath =
286-
// Registry.getStringValue(REGISTRY_ROOT_KEY.CURRENT_USER, keyPath, "AppData");
287-
288-
// Fix for Issue 410
289-
// Java 1.6 doesn't provide a good workaround (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6519127)
290-
// Using JNA and SHGetFolderPath instead.
291-
292271
// this will be contain the path if SHGetFolderPath is successful
293272
char[] pszPath = new char[WinDef.MAX_PATH];
294273
HRESULT hResult =
@@ -297,14 +276,13 @@ static private String getAppDataPath() throws Exception {
297276
pszPath);
298277

299278
if (!hResult.equals(WinError.S_OK)) {
300-
System.err.println(Kernel32Util.formatMessageFromHR(hResult));
301-
throw new Exception("Problem city, population: your computer.");
279+
//System.err.println(Kernel32Util.formatMessageFromHR(hResult));
280+
//throw new Exception("Problem city, population: your computer.");
281+
throw new Exception(Kernel32Util.formatMessageFromHR(hResult));
302282
}
303283

304284
String appDataPath = new String(pszPath);
305285
int len = appDataPath.indexOf("\0");
306-
// appDataPath = appDataPath.substring(0, len);
307-
// return new File(appDataPath, "Processing");
308286
return appDataPath.substring(0, len);
309287
}
310288

@@ -320,6 +298,9 @@ public File getDefaultSketchbookFolder() throws Exception {
320298

321299

322300
static private String getDocumentsPath() throws Exception {
301+
// heh, this is a little too cheeky
302+
//new JFileChooser().getFileSystemView().getDefaultDirectory().toString();
303+
323304
// http://support.microsoft.com/?kbid=221837&sd=RMVP
324305
// http://support.microsoft.com/kb/242557/en-us
325306

@@ -347,14 +328,11 @@ static private String getDocumentsPath() throws Exception {
347328
HRESULT hResult = Shell32.INSTANCE.SHGetFolderPath(null, ShlObj.CSIDL_PERSONAL, null, ShlObj.SHGFP_TYPE_CURRENT, pszPath);
348329

349330
if (!hResult.equals(WinError.S_OK)) {
350-
System.err.println(Kernel32Util.formatMessageFromHR(hResult));
351-
throw new Exception("Problem city, population: your computer.");
331+
throw new Exception(Kernel32Util.formatMessageFromHR(hResult));
352332
}
353333

354334
String personalPath = new String(pszPath);
355335
int len = personalPath.indexOf("\0");
356-
// personalPath = personalPath.substring(0, len);
357-
// return new File(personalPath, "Processing");
358336
return personalPath.substring(0, len);
359337
}
360338

0 commit comments

Comments
 (0)