@@ -1219,29 +1219,34 @@ private File mergeSketchWithBootloaderIfAppropriate(String className, Preference
1219
1219
1220
1220
//7. Save the .hex file
1221
1221
void saveHex () throws RunnerException {
1222
- if (!prefs .containsKey ("recipe.output.tmp_file" ) || !prefs .containsKey ("recipe.output.save_file" )) {
1222
+ List <String > compiledSketches = new ArrayList <>(prefs .subTree ("recipe.output.tmp_file" , 1 ).values ());
1223
+ List <String > copyOfCompiledSketches = new ArrayList <>(prefs .subTree ("recipe.output.save_file" , 1 ).values ());
1224
+
1225
+ if (isExportCompiledSketchSupported (compiledSketches , copyOfCompiledSketches )) {
1223
1226
System .err .println (_ ("Warning: This core does not support exporting sketches. Please consider upgrading it or contacting its author" ));
1224
1227
return ;
1225
1228
}
1226
1229
1227
1230
PreferencesMap dict = new PreferencesMap (prefs );
1228
1231
dict .put ("ide_version" , "" + BaseNoGui .REVISION );
1229
1232
1230
- try {
1231
- List <String > compiledSketches = new ArrayList <String >(prefs .subTree ("recipe.output.tmp_file" , 1 ).values ());
1232
- if (!compiledSketches .isEmpty ()) {
1233
- List <String > copyOfCompiledSketches = new ArrayList <String >(prefs .subTree ("recipe.output.save_file" , 1 ).values ());
1234
- for (int i = 0 ; i < compiledSketches .size (); i ++) {
1235
- saveHex (compiledSketches .get (i ), copyOfCompiledSketches .get (i ), prefs );
1236
- }
1237
- } else {
1233
+ if (!compiledSketches .isEmpty ()) {
1234
+ for (int i = 0 ; i < compiledSketches .size (); i ++) {
1235
+ saveHex (compiledSketches .get (i ), copyOfCompiledSketches .get (i ), prefs );
1236
+ }
1237
+ } else {
1238
+ try {
1238
1239
saveHex (prefs .getOrExcept ("recipe.output.tmp_file" ), prefs .getOrExcept ("recipe.output.save_file" ), prefs );
1240
+ } catch (PreferencesMapException e ) {
1241
+ throw new RunnerException (e );
1239
1242
}
1240
- } catch (Exception e ) {
1241
- throw new RunnerException (e );
1242
1243
}
1243
1244
}
1244
1245
1246
+ private boolean isExportCompiledSketchSupported (List <String > compiledSketches , List <String > copyOfCompiledSketches ) {
1247
+ return (compiledSketches .isEmpty () || copyOfCompiledSketches .isEmpty () || copyOfCompiledSketches .size () < compiledSketches .size ()) && (!prefs .containsKey ("recipe.output.tmp_file" ) || !prefs .containsKey ("recipe.output.save_file" ));
1248
+ }
1249
+
1245
1250
private void saveHex (String compiledSketch , String copyOfCompiledSketch , PreferencesMap dict ) throws RunnerException {
1246
1251
try {
1247
1252
compiledSketch = StringReplacer .replaceFromMapping (compiledSketch , dict );
0 commit comments