mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-21 15:54:39 +01:00
Do not crash if preferences.txt can't be written
This commit is contained in:
parent
99fe051c4a
commit
9eeb79fed4
@ -1,14 +1,9 @@
|
|||||||
package processing.app;
|
package processing.app;
|
||||||
|
|
||||||
import org.apache.commons.compress.utils.IOUtils;
|
import static processing.app.I18n.format;
|
||||||
|
import static processing.app.I18n.tr;
|
||||||
|
|
||||||
import cc.arduino.i18n.Languages;
|
import java.awt.Font;
|
||||||
import processing.app.helpers.PreferencesHelper;
|
|
||||||
import processing.app.helpers.PreferencesMap;
|
|
||||||
import processing.app.legacy.PApplet;
|
|
||||||
import processing.app.legacy.PConstants;
|
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
@ -18,7 +13,13 @@ import java.util.Iterator;
|
|||||||
import java.util.MissingResourceException;
|
import java.util.MissingResourceException;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static processing.app.I18n.tr;
|
import org.apache.commons.compress.utils.IOUtils;
|
||||||
|
|
||||||
|
import cc.arduino.i18n.Languages;
|
||||||
|
import processing.app.helpers.PreferencesHelper;
|
||||||
|
import processing.app.helpers.PreferencesMap;
|
||||||
|
import processing.app.legacy.PApplet;
|
||||||
|
import processing.app.legacy.PConstants;
|
||||||
|
|
||||||
|
|
||||||
public class PreferencesData {
|
public class PreferencesData {
|
||||||
@ -136,6 +137,9 @@ public class PreferencesData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
writer.flush();
|
writer.flush();
|
||||||
|
} catch (Throwable e) {
|
||||||
|
System.err.println(format(tr("Could not write preferences file: {0}"), e.getMessage()));
|
||||||
|
return;
|
||||||
} finally {
|
} finally {
|
||||||
IOUtils.closeQuietly(writer);
|
IOUtils.closeQuietly(writer);
|
||||||
}
|
}
|
||||||
|
@ -566,12 +566,9 @@ public class PApplet {
|
|||||||
if (file == null) {
|
if (file == null) {
|
||||||
throw new RuntimeException("File passed to createWriter() was null");
|
throw new RuntimeException("File passed to createWriter() was null");
|
||||||
} else {
|
} else {
|
||||||
e.printStackTrace();
|
throw new RuntimeException("Couldn't create a writer for " + file.getAbsolutePath(), e);
|
||||||
throw new RuntimeException("Couldn't create a writer for " +
|
|
||||||
file.getAbsolutePath());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user