fix for problem with forced save (bug #1456)

This commit is contained in:
benfry
2010-02-04 20:23:09 +00:00
parent e0ec0dbd95
commit cdd10c1d2c
2 changed files with 11 additions and 10 deletions

View File

@@ -560,7 +560,7 @@ public class Base {
* Replace the sketch in the current window with a new untitled document.
*/
public void handleNewReplace() {
if (!activeEditor.checkModified(false)) {
if (!activeEditor.checkModified()) {
return; // sketch was modified, and user canceled
}
// Close the running window, avoid window boogers with multiple sketches
@@ -592,7 +592,7 @@ public class Base {
* @param path Location of the primary pde file for the sketch.
*/
public void handleOpenReplace(String path) {
if (!activeEditor.checkModified(false)) {
if (!activeEditor.checkModified()) {
return; // sketch was modified, and user canceled
}
// Close the running window, avoid window boogers with multiple sketches
@@ -734,8 +734,8 @@ public class Base {
*/
public boolean handleClose(Editor editor) {
// Check if modified
boolean immediate = editors.size() == 1;
if (!editor.checkModified(immediate)) {
// boolean immediate = editors.size() == 1;
if (!editor.checkModified()) {
return false;
}
@@ -838,7 +838,7 @@ public class Base {
protected boolean handleQuitEach() {
int index = 0;
for (Editor editor : editors) {
if (editor.checkModified(true)) {
if (editor.checkModified()) {
// Update to the new/final sketch path for this fella
storeSketchPath(editor, index);
index++;

View File

@@ -1745,13 +1745,14 @@ public class Editor extends JFrame implements RunnerListener {
/**
* Check if the sketch is modified and ask user to save changes.
* Immediately should be set true when quitting, or when the save should
* not happen asynchronously. Come to think of it, that's always now?
* @return false if canceling the close/quit operation
*/
protected boolean checkModified(boolean immediately) {
protected boolean checkModified() {
if (!sketch.isModified()) return true;
// As of Processing 1.0.10, this always happens immediately.
// http://dev.processing.org/bugs/show_bug.cgi?id=1456
String prompt = "Save changes to " + sketch.getName() + "? ";
if (!Base.isMacOS()) {
@@ -1761,7 +1762,7 @@ public class Editor extends JFrame implements RunnerListener {
JOptionPane.QUESTION_MESSAGE);
if (result == JOptionPane.YES_OPTION) {
return handleSave(immediately);
return handleSave(true);
} else if (result == JOptionPane.NO_OPTION) {
return true; // ok to continue
@@ -1813,7 +1814,7 @@ public class Editor extends JFrame implements RunnerListener {
Object result = pane.getValue();
if (result == options[0]) { // save (and close/quit)
return handleSave(immediately);
return handleSave(true);
} else if (result == options[2]) { // don't save (still close/quit)
return true;