fixed a bug: undo sets the correct modified state if all modifications are undone since last save.

This commit is contained in:
hneemann 2017-06-02 10:07:01 +02:00
parent 303318a256
commit 367c710efa
2 changed files with 19 additions and 1 deletions

View File

@ -1081,7 +1081,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
private void saveFile(File filename, boolean toPrefs) {
try {
circuitComponent.getCircuit().save(filename);
circuitComponent.save(filename);
ensureModelIsStopped();
setFilename(filename, toPrefs);

View File

@ -30,6 +30,8 @@ import java.awt.geom.AffineTransform;
import java.awt.geom.NoninvertibleTransformException;
import java.awt.geom.Point2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
@ -107,6 +109,7 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
private ArrayList<Modification> modifications;
private Circuit initialCircuit;
private int undoPosition;
private int savedUndoPosition;
private Style highLightStyle = Style.HIGHLIGHT;
@ -381,6 +384,10 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
redoAction.setEnabled(true);
if (undoPosition == 0)
undoAction.setEnabled(false);
if (undoPosition != savedUndoPosition)
circuit.modified();
circuit.fireChangedEvent();
repaintNeeded();
}
@ -414,6 +421,17 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
return Lang.get("menu_redo_tt");
}
/**
* save the circuit
*
* @param filename the filename
* @throws IOException IOException
*/
public void save(File filename) throws IOException {
circuit.save(filename);
savedUndoPosition = undoPosition;
}
/**
* @return the main frame
*/