#17350 closed defect (fixed)
[Patch] Autosave makes JOSM think layer is saved
Reported by: | ShadowFoxNixill | Owned by: | team |
---|---|---|---|
Priority: | normal | Milestone: | 19.10 |
Component: | Core | Version: | |
Keywords: | template_report autosave | Cc: |
Description
What steps will reproduce the problem?
- Open a map from an existing file (make sure "Discourage upload" is turned on)
- Make some modifications
- Wait for JOSM to autosave
What is the expected result?
JOSM should act as if the file hasn't been saved, as it actually hasn't (the autosave goes to a backup file). This means:
Title bar: Should display an asterisk
Attempting to close JOSM or remove the layer: Should prompt you to save the layer first
What happens instead?
JOSM acts as if a regular save to the file being modified has occurred, meaning:
Title bar: Doesn't display an asterisk
Attempting to close JOSM or remove the layer: Does so without any prompt
Please provide any additional information below. Attach a screenshot if possible.
URL:https://josm.openstreetmap.de/svn/trunk Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b Last:Changed Date: 2019-02-15 20:59:09 +0100 (Fri, 15 Feb 2019) Build-Date:2019-02-16 02:30:55 Revision:14790 Relative:URL: ^/trunk Identification: JOSM/1.5 (14790 en) Windows 10 64-Bit OS Build number: Windows 10 Education 1803 (17134) Memory Usage: 1997 MB / 1997 MB (869 MB allocated, but free) Java version: 1.8.0_201-b09, Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM Screen: \Display0 1920x1080, \Display1 1920x1080 Maximum Screen Size: 1920x1080 VM arguments: [-Djava.security.manager, -Djava.security.policy=file:<java.home>\lib\security\javaws.policy, -DtrustProxy=true, -Djnlpx.home=<java.home>\bin, -Djnlpx.origFilenameArg=%UserProfile%\Programs\josm-latest.jnlp, -Djnlpx.remove=false, -Djava.util.Arrays.useLegacyMergeSort=true, -Djnlpx.heapsize=NULL,2048m, -Djnlpx.splashport=62966, -Djnlpx.jvm=<java.home>\bin\javaw.exe] Dataset consistency test: No problems found Plugins: + apache-commons (34506) + continuosDownload (82) + ejml (34389) + geotools (34513) + jaxb (34678) + jts (34524) + opendata (34867) + pbf (34867) + utilsplugin2 (34867) Map paint styles: + https://github.com/bastik/mapcss-tools/raw/osm/mapnik2mapcss/osm-results/mapnik.zip Last errors/warnings: - W: java.io.IOException: Attribution is not loaded yet - W: java.io.IOException: Attribution is not loaded yet - W: java.io.IOException: Attribution is not loaded yet - W: java.io.IOException: Attribution is not loaded yet - W: java.io.IOException: Tags to paste are not valid. - W: java.io.IOException: Tags to paste are not valid. - W: JOSM expected to find primitive [way 42372917] in dataset but it is not there. Please report this at https://josm.openstreetmap.de. This is not a critical error, it should be safe to continue in your work. - E: java.lang.Exception - W: JOSM expected to find primitive [way 42372917] in dataset but it is not there. Please report this at https://josm.openstreetmap.de. This is not a critical error, it should be safe to continue in your work. - E: java.lang.Exception
Attachments (0)
Change History (8)
comment:1 by , 6 years ago
Keywords: | autosave added |
---|
comment:2 by , 6 years ago
comment:4 by , 5 years ago
If you load a layer from file with upload=never
, the File.Save
Menu will be enabled on changes and disabled, if you save the file. But when AutoSave saves the layer (in the "AutoSave" folder, also the "Save" will be disabled for the original file location. You can only save with Save As...
and hopefully override the correct file or you loose the changes in the original file on closing the layer / ending JOSM because no warning about unsaved data occur. I lost may edits in files because I closed JOSM and did not remember to manually save the changes in that layer!
I see three different locations to "persist" a layer: Upload, File and AutoSave. Each needs to track separately where are unsaved changes. But AutoSave should never mark the normal File as saved!
Steps to reproduce:
- Reduce AutoSave interval to 30 seconds.
- load any file -> File.Save is disabled (OK)
- do any modification -> File.Save is enabled (OK)
- Open File Menu and wait - after a wile File.Save will be disabled without any interaction of the user. (not ok)
comment:5 by , 5 years ago
Summary: | Autosave makes JOSM think layer is saved → [Patch] Autosave makes JOSM think layer is saved |
---|
The onPostSaveToFile
event shouldn't be fired on autosave since it didn't actually save (at least not in a way the layer would expect when this event is fired).
@mdk, quoting from the other ticket:
Without knowing the code I assume, that there are two modified flags for each layer: one for upload and one for saving as file. Both flags are set on any modification, but the file_modified flag is cleaed on save and the upload_modified flag is cleared an upload.
AutosaveTask
keeps track of the changes itself (Set<DataSet> changedDatasets
, filled by listening to processDatasetEvent
), so we don't even need a third flag. But other than that, yes the problem is that the flag requiresSaveToFile
is reset on autosave (because of the misleading event).
@Don-vip:
-
src/org/openstreetmap/josm/gui/io/importexport/OsmExporter.java
65 65 * Exports OSM data to the given file. 66 66 * @param file Output file 67 67 * @param layer Data layer. Must be an instance of {@link OsmDataLayer}. 68 * @param noBackupif {@code true}, the potential backup file created if the output file already exists will be deleted69 * after a successful export68 * @param isAutosave if {@code true}, the potential backup file created if the output file already exists will be deleted 69 * after a successful export and post-save events won't be fired 70 70 * @throws IOException in case of IO errors 71 71 * @throws InvalidPathException when file name cannot be converted into a Path 72 72 * @throws IllegalArgumentException if {@code layer} is not an instance of {@code OsmDataLayer} 73 73 */ 74 public void exportData(File file, Layer layer, boolean noBackup) throws IOException {74 public void exportData(File file, Layer layer, boolean isAutosave) throws IOException { 75 75 if (!(layer instanceof OsmDataLayer)) { 76 76 throw new IllegalArgumentException( 77 77 MessageFormat.format("Expected instance of OsmDataLayer. Got ''{0}''.", layer.getClass().getName())); 78 78 } 79 save(file, (OsmDataLayer) layer, noBackup);79 save(file, (OsmDataLayer) layer, isAutosave); 80 80 } 81 81 82 82 protected static OutputStream getOutputStream(File file) throws IOException { … … 83 83 return Compression.getCompressedFileOutputStream(file); 84 84 } 85 85 86 private void save(File file, OsmDataLayer layer, boolean noBackup) throws IOException {86 private void save(File file, OsmDataLayer layer, boolean isAutosave) throws IOException { 87 87 File tmpFile = null; 88 88 try { 89 89 if (file.exists() && !file.canWrite()) { … … 98 98 } 99 99 100 100 doSave(file, layer); 101 if (( noBackup|| !Config.getPref().getBoolean("save.keepbackup", false)) && tmpFile != null) {101 if ((isAutosave || !Config.getPref().getBoolean("save.keepbackup", false)) && tmpFile != null) { 102 102 Utils.deleteFile(tmpFile); 103 103 } 104 layer.onPostSaveToFile(); 104 if (!isAutosave) { 105 layer.onPostSaveToFile(); 106 } 105 107 } catch (IOException | InvalidPathException e) { 106 108 Logging.error(e);
comment:6 by , 5 years ago
Milestone: | → 19.10 |
---|
If I remeber corrctly this is not related to autosave. JOSM never checks for changes in layers with upload=no (which should be changed in my opinion. There should already be a ticket for this somewhere.)