turn off file change detection (#2852)

This commit is contained in:
Ben Fry
2014-09-10 17:35:36 -04:00
parent bd4916036c
commit 20aa52d67a
4 changed files with 25 additions and 45 deletions

View File

@@ -2359,7 +2359,8 @@ public abstract class Editor extends JFrame implements RunnerListener {
Base.showWarning("Error", "Could not create the sketch.", e);
return false;
}
if (Preferences.getBoolean("editor.watcher")) {
// Disabling for 3.0a4
if (false && Preferences.getBoolean("editor.watcher")) {
initFileChangeListener();
}
@@ -2397,12 +2398,11 @@ public abstract class Editor extends JFrame implements RunnerListener {
private void initFileChangeListener() {
try {
WatchService watchService = FileSystems.getDefault().newWatchService();
watcherKey = sketch
.getFolder()
.toPath()
.register(watchService, StandardWatchEventKinds.ENTRY_CREATE,
StandardWatchEventKinds.ENTRY_DELETE,
StandardWatchEventKinds.ENTRY_MODIFY);
Path sp = sketch.getFolder().toPath();
watcherKey = sp.register(watchService,
StandardWatchEventKinds.ENTRY_CREATE,
StandardWatchEventKinds.ENTRY_DELETE,
StandardWatchEventKinds.ENTRY_MODIFY);
} catch (IOException e) {
e.printStackTrace();
}
@@ -2460,8 +2460,9 @@ public abstract class Editor extends JFrame implements RunnerListener {
for (WatchEvent<?> e : events) {
boolean sketchFile = false;
Path file = ((Path) e.context()).getFileName();
System.out.println(file);
for (String s : getMode().getExtensions()) {
//if it is a change to a file with a known extension
// if it is a change to a file with a known extension
if (file.toString().endsWith(s)) {
sketchFile = true;
break;
@@ -2472,11 +2473,11 @@ public abstract class Editor extends JFrame implements RunnerListener {
continue;
}
int response = Base
.showYesNoQuestion(Editor.this,
"File Modified",
"Your sketch has been modified externally",
"Would you like to reload the sketch?");
int response =
Base.showYesNoQuestion(Editor.this,
"File Modified",
"Your sketch has been modified externally",
"Would you like to reload the sketch?");
if (response == 0) {
//grab the 'main' code in case this reload tries to delete everything
File sc = sketch.getMainFile();
@@ -2486,17 +2487,15 @@ public abstract class Editor extends JFrame implements RunnerListener {
header.rebuild();
} catch (Exception f) {
if (sketch.getCodeCount() < 1) {
Base
.showWarning("Canceling Reload",
"You cannot delete the last code file in a sketch!");
Base.showWarning("Canceling Reload",
"You cannot delete the last code file in a sketch.");
//if they deleted the last file, re-save the SketchCode
try {
//make a blank file
sc.createNewFile();
} catch (IOException e1) {
//if that didn't work, tell them it's un-recoverable
Base.showError("Reload failed",
"The sketch contians no code files", e1);
Base.showError("Reload failed", "The sketch contains no code files", e1);
//don't try to reload again after the double fail
//this editor is probably trashed by this point, but a save-as might be possible
break;

View File

@@ -3,6 +3,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2012-14 The Processing Foundation
Copyright (c) 2011-12 Ben Fry and Casey Reas
This program is free software; you can redistribute it and/or modify
@@ -54,7 +55,6 @@ public class SingleInstance {
*/
static boolean alreadyRunning(String[] args) {
return Preferences.get(SERVER_PORT) != null && sendArguments(args);
// sendArguments(args, 5000));
}
@@ -125,25 +125,9 @@ public class SingleInstance {
static boolean sendArguments(String[] args) { //, long timeout) {
try {
//int port = Integer.parseInt(Preferences.get("server.port"));
//String key = Preferences.get("server.key");
int port = Preferences.getInteger(SERVER_PORT);
String key = Preferences.get(SERVER_KEY);
// long endTime = System.currentTimeMillis() + timeout;
//
// Socket socket = null;
// while (socket == null && System.currentTimeMillis() < endTime) {
// try {
// socket = new Socket(InetAddress.getByName(null), port);
// } catch (Exception ioe) {
// try {
// Thread.sleep(50);
// } catch (InterruptedException ie) {
// Thread.yield();
// }
// }
// }
Socket socket = null;
try {
socket = new Socket(InetAddress.getByName(null), port);
@@ -151,15 +135,10 @@ public class SingleInstance {
if (socket != null) {
PrintWriter writer = PApplet.createWriter(socket.getOutputStream());
// bw.write(key + "\n");
writer.println(key);
for (String arg : args) {
// if (filename != null) {
//// bw.write(filename + "\n");
// writer.println(filename);
writer.println(arg);
}
// bw.close();
writer.flush();
writer.close();
return true;

View File

@@ -1,6 +1,4 @@
0231 core (3.0a4 or 3.0b1)
_ TGAs created with saveFrame() have an alpha channel, which breaks Movie Maker
_ https://github.com/processing/processing/issues/2851
applet/component

View File

@@ -11,6 +11,8 @@ X make a new preference setting for the default mode
X this will set folks to the PDE X mode, and prevent conflicts w/ 2.0
X change last.sketch.mode to mode.last
X fix OS X default File menu to be the same order as the other File menu
X TGAs from saveFrame() create transparent/black movies with Movie Maker
X https://github.com/processing/processing/issues/2851
before launch
@@ -41,10 +43,9 @@ _ check on pull for mnemonics
_ https://github.com/processing/processing/pull/2382
_ remove toolbar menu references and code to rebuild
high
_ "Your sketch has been modified externally" appear without reason
_ https://github.com/processing/processing/issues/2852
_ export application ubuntu -> windows not working (2.2.1)
_ https://github.com/processing/processing/issues/2698
_ might be something with libraries (native or otherwise)
@@ -93,6 +94,9 @@ _ https://github.com/processing/processing/issues/2199
medium
_ remove toolbar menu references and code to rebuild
_ fix single instance server on OS X to load double-clicked files
_ when run from Eclipse, the single instance thing punts
_ 'recent' menu needs to recognize the p5 app folder
_ also should recognize the user's home dir
_ possibility of libraries folder inside a particular sketch?