mirror of
https://github.com/processing/processing4.git
synced 2026-02-04 06:09:17 +01:00
prevent infinite "sketch disappeared" warnings (fixes #4805)
This commit is contained in:
@@ -40,7 +40,9 @@ import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -1497,29 +1499,36 @@ public class Sketch {
|
||||
*/
|
||||
|
||||
|
||||
private Set<File> existenceWarnings = new HashSet<>();
|
||||
|
||||
/**
|
||||
* Make sure the sketch hasn't been moved or deleted by some
|
||||
* nefarious user. If they did, try to re-create it and save.
|
||||
* Only checks to see if the main folder is still around,
|
||||
* but not its contents.
|
||||
* Make sure the sketch hasn't been moved or deleted by a nefarious user.
|
||||
* If they did, try to re-create it and save. Only checks whether the
|
||||
* main folder is still around, but not its contents.
|
||||
*/
|
||||
public void ensureExistence() {
|
||||
if (!folder.exists()) {
|
||||
// Disaster recovery, try to salvage what's there already.
|
||||
Messages.showWarning(Language.text("ensure_exist.messages.missing_sketch"),
|
||||
Language.text("ensure_exist.messages.missing_sketch.description"));
|
||||
try {
|
||||
folder.mkdirs();
|
||||
modified = true;
|
||||
// Avoid an infinite loop if we've already warned about this
|
||||
// https://github.com/processing/processing/issues/4805
|
||||
if (!existenceWarnings.contains(folder)) {
|
||||
existenceWarnings.add(folder);
|
||||
|
||||
for (int i = 0; i < codeCount; i++) {
|
||||
code[i].save(); // this will force a save
|
||||
// Disaster recovery, try to salvage what's there already.
|
||||
Messages.showWarning(Language.text("ensure_exist.messages.missing_sketch"),
|
||||
Language.text("ensure_exist.messages.missing_sketch.description"));
|
||||
try {
|
||||
folder.mkdirs();
|
||||
modified = true;
|
||||
|
||||
for (int i = 0; i < codeCount; i++) {
|
||||
code[i].save(); // this will force a save
|
||||
}
|
||||
calcModified();
|
||||
|
||||
} catch (Exception e) {
|
||||
Messages.showWarning(Language.text("ensure_exist.messages.unrecoverable"),
|
||||
Language.text("ensure_exist.messages.unrecoverable.description"), e);
|
||||
}
|
||||
calcModified();
|
||||
|
||||
} catch (Exception e) {
|
||||
Messages.showWarning(Language.text("ensure_exist.messages.unrecoverable"),
|
||||
Language.text("ensure_exist.messages.unrecoverable.description"), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
12
todo.txt
12
todo.txt
@@ -22,6 +22,12 @@ jakub
|
||||
X Fix sketch exception getting hidden by warning
|
||||
X https://github.com/processing/processing/pull/5486
|
||||
X https://github.com/processing/processing/issues/5412
|
||||
X EventQueue problems with "could not find sketch size" message
|
||||
X https://github.com/processing/processing/issues/4893
|
||||
X https://github.com/processing/processing/pull/5708
|
||||
X https://github.com/processing/processing/issues/5030 (duplicate)
|
||||
X size(0, 0) just freezes instead of showing an error
|
||||
X https://github.com/processing/processing/issues/5233 (duplicate)
|
||||
|
||||
|
||||
_ Find in Reference disabled for various keywords (draw, for, if, catch, while)
|
||||
@@ -38,12 +44,6 @@ _ seen in Eclipse; have to turn on the debugger
|
||||
_ "Sketch disappeared" infinite pop up dialogs
|
||||
_ https://github.com/processing/processing/pull/4808
|
||||
_ https://github.com/processing/processing/issues/4805
|
||||
_ EventQueue problems with "could not find sketch size" message
|
||||
_ https://github.com/processing/processing/issues/4893
|
||||
X https://github.com/processing/processing/pull/5708
|
||||
X https://github.com/processing/processing/issues/5030 (duplicate)
|
||||
_ size(0, 0) just freezes instead of showing an error
|
||||
X https://github.com/processing/processing/issues/5233 (duplicate)
|
||||
|
||||
|
||||
manager
|
||||
|
||||
Reference in New Issue
Block a user