diff --git a/app/src/processing/app/Settings.java b/app/src/processing/app/Settings.java index 020c20d38..b51b37570 100644 --- a/app/src/processing/app/Settings.java +++ b/app/src/processing/app/Settings.java @@ -94,14 +94,18 @@ public void load(File additions) { // check for platform-specific properties in the defaults String platformExt = "." + Platform.getName(); int platformExtLength = platformExt.length(); + HashMap tmpMap = new HashMap<>(); for (String key : table.keySet()) { if (key.endsWith(platformExt)) { // this is a key specific to a particular platform String actualKey = key.substring(0, key.length() - platformExtLength); String value = get(key); - table.put(actualKey, value); + //if the key is specific to this platform and is not the last property then attempting to append it to the map will throw a ConcurrentModificationException + //to avoid this we append it to a temporary map that can then be safely merged after the loop is complete + tmpMap.put(actualKey, value); } } + table.putAll(tmpMap); } diff --git a/java/src/processing/mode/java/JavaBuild.java b/java/src/processing/mode/java/JavaBuild.java index b367e2c8f..a76a3f819 100644 --- a/java/src/processing/mode/java/JavaBuild.java +++ b/java/src/processing/mode/java/JavaBuild.java @@ -735,7 +735,18 @@ protected boolean exportApplication(File destFolder, File resourcesFolder = new File(contentsFolder, "Resources"); Util.copyDir(new File(contentsOrig, "Resources/en.lproj"), new File(resourcesFolder, "en.lproj")); - Util.copyFile(mode.getContentFile("application/application.icns"), + + Settings sketchProperties = new Settings(new File(sketch.getFolder(), "sketch.properties")); + String iconPath = sketchProperties.get("icon");//icon.macos + File iconFile; + if(iconPath == null || iconPath.isEmpty()){ + iconFile = mode.getContentFile("application/application.icns"); + System.out.println("using default icon"); + }else { + iconFile = new File(sketch.getFolder(), iconPath); + System.out.println("found custom icon: "+iconPath); + } + Util.copyFile(iconFile, new File(resourcesFolder, "application.icns")); } else if (exportPlatform == PConstants.LINUX) { @@ -958,7 +969,17 @@ protected boolean exportApplication(File destFolder, File exeFile = new File(destFolder, sketch.getName() + ".exe"); config.addChild("outfile").setContent(exeFile.getAbsolutePath()); - File iconFile = mode.getContentFile("application/application.ico"); + //check sketch.properties to see if an icon was set + Settings sketchProperties = new Settings(new File(sketch.getFolder(), "sketch.properties")); + String iconPath = sketchProperties.get("icon");//icon.windows + File iconFile; + if(iconPath == null || iconPath.isEmpty()){ + iconFile = mode.getContentFile("application/application.ico"); + System.out.println("using default icon"); + }else { + iconFile = new File(sketch.getFolder(), iconPath); + System.out.println("found custom icon: "+iconPath); + } config.addChild("icon").setContent(iconFile.getAbsolutePath()); XML clazzPath = config.addChild("classPath");