Skip to content

Commit 33f5c53

Browse files
committed
Implemented OS specific preferences
1 parent af5de4e commit 33f5c53

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Diff for: app/src/processing/app/helpers/PreferencesMap.java

+22
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@
2929
import java.io.IOException;
3030
import java.io.InputStream;
3131
import java.util.HashMap;
32+
import java.util.HashSet;
3233
import java.util.Hashtable;
3334
import java.util.Map;
35+
import java.util.Set;
3436

37+
import processing.app.Base;
3538
import processing.core.PApplet;
3639

3740
public class PreferencesMap extends HashMap<String, String> {
@@ -78,6 +81,25 @@ public void load(InputStream input) throws IOException {
7881
put(key.trim(), value.trim());
7982
}
8083
}
84+
85+
// This is needed to avoid ConcurrentAccessExceptions
86+
Set<String> keys = new HashSet<String>(keySet());
87+
88+
// Override keys that have OS specific versions
89+
for (String k : keys) {
90+
boolean replace = false;
91+
if (Base.isLinux() && k.endsWith(".linux"))
92+
replace = true;
93+
if (Base.isWindows() && k.endsWith(".windows"))
94+
replace = true;
95+
if (Base.isMacOS() && k.endsWith(".macos"))
96+
replace = true;
97+
if (replace) {
98+
int dot = k.lastIndexOf('.');
99+
String overridenKey = k.substring(0, dot);
100+
put(overridenKey, get(k));
101+
}
102+
}
81103
}
82104

83105
/**

0 commit comments

Comments
 (0)