Opened 3 years ago

Last modified 3 years ago

#22817 closed defect

[patch] No warning deleting a data layer with changes and discouraged upload set — at Version 2

Reported by: skyper Owned by: team
Priority: major Milestone: 23.04
Component: Core Version: latest
Keywords: template_report modified data layer discouraged state save Cc:

Description (last modified by gaben)

What steps will reproduce the problem?

  1. Download new data
  2. Make some changes
  3. Set "discourage upload" on the layer
  4. Delete layer

What is the expected result?

Upload/Save dialog with upload disabled

What happens instead?

Layer is deleted without any warning

Please provide any additional information below. Attach a screenshot if possible.

Did not try upload=never but the dialog should still be displayed.

Relative:URL: ^/trunk
Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b
Last:Changed Date: 2023-03-13 21:59:27 +0100 (Mon, 13 Mar 2023)
Revision:18690
Build-Date:2023-03-14 02:30:58
URL:https://josm.openstreetmap.de/svn/trunk

Change History (2)

comment:1 by skyper, 3 years ago

Priority: normalcritical

With current behavior, you can loose all you work, e.g. a private file of all you mushroom spots.

comment:2 by gaben, 3 years ago

Description: modified (diff)
Milestone: 23.03
Priority: criticalmajor
Summary: No warning deleting a data layer with changes and discouraged upload set[patch] No warning deleting a data layer with changes and discouraged upload set
  • src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java

     
    112112    public static boolean saveUnsavedModifications(Iterable<? extends Layer> selectedLayers, Reason reason) {
    113113        if (!GraphicsEnvironment.isHeadless()) {
    114114            SaveLayersDialog dialog = new SaveLayersDialog(MainApplication.getMainFrame());
    115             List<AbstractModifiableLayer> layersWithUnmodifiedChanges = new ArrayList<>();
     115            List<AbstractModifiableLayer> layersWithUnsavedChanges = new ArrayList<>();
    116116            for (Layer l: selectedLayers) {
    117117                if (!(l instanceof AbstractModifiableLayer)) {
    118118                    continue;
     
    121121                if (odl.isModified() &&
    122122                        ((!odl.isSavable() && !odl.isUploadable()) ||
    123123                                odl.requiresSaveToFile() ||
    124                                 (odl.requiresUploadToServer() && !odl.isUploadDiscouraged()))) {
    125                     layersWithUnmodifiedChanges.add(odl);
     124                                odl.requiresUploadToServer())) {
     125                    layersWithUnsavedChanges.add(odl);
    126126                }
    127127            }
    128128            dialog.prepareForSavingAndUpdatingLayers(reason);
    129             if (!layersWithUnmodifiedChanges.isEmpty()) {
    130                 dialog.getModel().populate(layersWithUnmodifiedChanges);
     129            if (!layersWithUnsavedChanges.isEmpty()) {
     130                dialog.getModel().populate(layersWithUnsavedChanges);
    131131                dialog.setVisible(true);
    132132                switch(dialog.getUserAction()) {
    133133                    case PROCEED: return true;

The upload=never option is not affected as in that case the isUploadable() returns false anyway.

I renamed the layersWithUnmodifiedChanges local variable to something more meaningful because the current naming contradicts.

Also whoever commits, the !odl.isSavable() && !odl.isUploadable() seems suspicious. When does it happen?

Note: See TracTickets for help on using tickets.