Changeset 15474 in josm


Ignore:
Timestamp:
2019-10-25T23:42:46+02:00 (5 years ago)
Author:
Don-vip
Message:

fix #17350 - don't fire post-save event when autosaving a file (patch by Bjoeni)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/io/importexport/OsmExporter.java

    r14982 r15474  
    6666     * @param file Output file
    6767     * @param layer Data layer. Must be an instance of {@link OsmDataLayer}.
    68      * @param noBackup if {@code true}, the potential backup file created if the output file already exists will be deleted
    69      *                 after a successful export
     68     * @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
    7070     * @throws IOException in case of IO errors
    7171     * @throws InvalidPathException when file name cannot be converted into a Path
    7272     * @throws IllegalArgumentException if {@code layer} is not an instance of {@code OsmDataLayer}
    7373     */
    74     public void exportData(File file, Layer layer, boolean noBackup) throws IOException {
     74    public void exportData(File file, Layer layer, boolean isAutosave) throws IOException {
    7575        if (!(layer instanceof OsmDataLayer)) {
    7676            throw new IllegalArgumentException(
    7777                    MessageFormat.format("Expected instance of OsmDataLayer. Got ''{0}''.", layer.getClass().getName()));
    7878        }
    79         save(file, (OsmDataLayer) layer, noBackup);
     79        save(file, (OsmDataLayer) layer, isAutosave);
    8080    }
    8181
     
    8484    }
    8585
    86     private void save(File file, OsmDataLayer layer, boolean noBackup) throws IOException {
     86    private void save(File file, OsmDataLayer layer, boolean isAutosave) throws IOException {
    8787        File tmpFile = null;
    8888        try {
     
    9999
    100100            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) {
    102102                Utils.deleteFile(tmpFile);
    103103            }
    104             layer.onPostSaveToFile();
     104            if (!isAutosave) {
     105                layer.onPostSaveToFile();
     106            }
    105107        } catch (IOException | InvalidPathException e) {
    106108            Logging.error(e);
Note: See TracChangeset for help on using the changeset viewer.