From 0a94239a38d78c696690f3cdbb8bb95f8ea8944d Mon Sep 17 00:00:00 2001 From: Patrick Vares Date: Thu, 29 Jan 2015 18:39:29 -0500 Subject: [PATCH] Switched ChangeDetector to use the last modified times from processing (when the file was last saved or loaded) and compare with the system's last modified time. Added supporting code in SketchCode to get these times. Added a tiny fix in Sketch to allow processing to actually start --- app/src/processing/app/ChangeDetector.java | 8 +++----- app/src/processing/app/Sketch.java | 3 ++- app/src/processing/app/SketchCode.java | 1 + 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/processing/app/ChangeDetector.java b/app/src/processing/app/ChangeDetector.java index bfb6fa6e6..907c27101 100644 --- a/app/src/processing/app/ChangeDetector.java +++ b/app/src/processing/app/ChangeDetector.java @@ -14,7 +14,8 @@ public class ChangeDetector implements WindowFocusListener { private Editor editor; // private boolean enabled = true; - private boolean enabled = false; // broken on OS X + //REMOVE on for testing + private boolean enabled = true; // broken on OS X private boolean skip = false; @@ -39,9 +40,6 @@ public class ChangeDetector implements WindowFocusListener { } private void checkFileChangeAsync() { - if(1==1){ - return; - } Thread th = new Thread(new Runnable() { @Override public void run() { @@ -159,7 +157,7 @@ public class ChangeDetector implements WindowFocusListener { reloadSketch(sc); return; } - //if a file's tab was visited after the file was + //if a file's tab was saved before the file was if (sketchFile.lastModified() > sc.lastModified()) { reloadSketch(sc); return; diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index 12aac7b9b..8d138bb14 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -1210,12 +1210,13 @@ public class Sketch { current = code[which]; currentIndex = which; current.visited = System.currentTimeMillis(); + //REMOVE try { editor.setCode(current); // editor.header.rebuild(); editor.header.repaint(); } catch (NullPointerException e) { - e.printStackTrace(); + //e.printStackTrace(); } } diff --git a/app/src/processing/app/SketchCode.java b/app/src/processing/app/SketchCode.java index ece13e702..38399cd04 100644 --- a/app/src/processing/app/SketchCode.java +++ b/app/src/processing/app/SketchCode.java @@ -296,6 +296,7 @@ public class SketchCode { System.err.println(); } + lastModified = file.lastModified(); setModified(false); }