fix bug when changing the Mode between Java and Android

This commit is contained in:
Ben Fry
2022-02-05 08:16:39 -05:00
parent a8e95d5e2d
commit 2b02203f5d
2 changed files with 11 additions and 4 deletions
+7 -4
View File
@@ -971,6 +971,7 @@ public class Base {
*/
private void saveModeSettings(final File sketchProps, final Mode mode) {
try {
// Read the old sketch.properties file if it already exists
final Settings settings = new Settings(sketchProps);
settings.set("mode", mode.getTitle());
settings.set("mode.id", mode.getIdentifier());
@@ -982,6 +983,7 @@ public class Base {
String getDefaultModeIdentifier() {
// Used to initialize coreModes, so cannot use coreModes[0].getIdentifier()
return "processing.mode.java.JavaMode";
}
@@ -1001,7 +1003,9 @@ public class Base {
nextMode = mode;
if (sketch.isModified()) {
handleNew(); // don't bother with error messages, just switch
// If sketch is modified, simpler to just open a new window.
// https://github.com/processing/processing4/issues/189
handleNew();
return false;
} else if (sketch.isUntitled()) {
@@ -1013,10 +1017,9 @@ public class Base {
} else {
// If the current sketch contains file extensions that the new mode
// can handle, then write a sketch.properties file with the new mode
// specified, and reopen. (Really only useful for Java <-> Android)
//if (isCompatible(sketch, mode)) {
// specified, and reopen. Currently, only used for Java <-> Android.
if (mode.canEdit(sketch)) {
final File props = new File(sketch.getCodeFolder(), "sketch.properties");
final File props = new File(sketch.getFolder(), "sketch.properties");
saveModeSettings(props, nextMode);
handleClose(activeEditor, true);
Editor editor = handleOpen(sketch.getMainFilePath());
+4
View File
@@ -3,6 +3,10 @@ X update to Java 17.0.2+8
X move "Add Examples" to bottom of the Examples window
X remove anachronistic Preferences.save() that happens after opening a sketch
modes and properties
X fix bug when changing the Mode between Java and Android
X appears that it would have been broken for a long time
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .