notes about change detection, clean up handler

This commit is contained in:
Ben Fry
2015-05-11 18:09:32 -04:00
parent f48648a264
commit ca381b2128
2 changed files with 19 additions and 15 deletions
+9 -15
View File
@@ -14,7 +14,11 @@ import javax.swing.JOptionPane;
public class ChangeDetector implements WindowFocusListener {
private Sketch sketch;
private Editor editor;
// Windows and others seem to have a few hundred ms difference in reported
// times, so we're arbitrarily setting a gap in time here.
// Mac OS X has an (exactly) one second difference. Not sure if it's a Java
// bug or something else about how OS X is writing files.
private final int MODIFIED_TIME_BUFFER = 1000;
// Set true if the user selected 'no'. TODO this can't just skip once,
@@ -111,26 +115,16 @@ public class ChangeDetector implements WindowFocusListener {
File sketchFile = sc.getFile();
if (sketchFile.exists()) {
long diff = sketchFile.lastModified() - sc.lastModified();
if (diff != 0) {
if (Base.isMacOS() && diff < 1000L + MODIFIED_TIME_BUFFER) {
// System.err.println("within buffer mac");
// Mac OS X has a one second difference. Not sure if it's a Java bug
// or something else about how OS X is writing files.
continue;
} else if (diff < MODIFIED_TIME_BUFFER) {
//if the file was modified within some reasonable time, then ignore it
// System.err.println("within buffer not mac");
continue;
}
// System.out.println(sketchFile.getName() + " " + diff);
if (diff > MODIFIED_TIME_BUFFER) {
//System.out.println(sketchFile.getName() + " " + diff);
reloadSketch(sc);
return;
//return;
}
} else {
// If a file in the sketch was not found, then it must have been
// deleted externally, so reload the sketch.
reloadSketch(sc);
return;
//return;
}
}
}
+10
View File
@@ -17,6 +17,14 @@ X https://github.com/processing/processing/pull/3227
X keep tab menu at the right-hand side
X https://github.com/processing/processing/pull/3236
sketch reloading
X "Your sketch has been modified externally..." appears erroneously
X https://github.com/processing/processing/issues/3222
X Prevent breakpoints from causing a reload prompt
X https://github.com/processing/processing/pull/3263
X Added buffer to file detection time
X https://github.com/processing/processing/pull/3262
akarshit
X preferences window fixes for Linux
X https://github.com/processing/processing/pull/3232
@@ -31,6 +39,8 @@ X Use system proxy by default
X https://github.com/processing/processing/issues/1476
X https://github.com/processing/processing/pull/3251
_ "run sketches on display" not working in 3.0a7
_ https://github.com/processing/processing/issues/3264
_ "one file added to sketch" message when two files added
_ Cmd-click behavior on function/variable is firing when cmd-click not pressed
_ https://github.com/processing/processing/issues/3242