Modify

#22817 closed defect (fixed)

[patch] No warning deleting a data layer with changes and discouraged upload set

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

Attachments (0)

Change History (5)

comment:1 by skyper, 20 months 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, 20 months 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?

comment:3 by taylor.smock, 20 months ago

Milestone: 23.0323.04

Ticket retargeted after milestone closed

in reply to:  2 comment:4 by taylor.smock, 19 months ago

Replying to gaben:

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?

isSavable() is used to check whether or not the layer can be saved. This will return true in most cases, while isUploadable() checks to see if the data can be uploaded (false for BLOCKED, other data sources can modify this while still being savable, or not be savable while being uploadable).

upload=never is affected since requiresUploadToServer checks to see if upload is blocked.

Anyway, I've got a test case for all three upload policy states, so we can be relatively certain that the bug in this section of code is "fixed".

comment:5 by taylor.smock, 19 months ago

Resolution: fixed
Status: newclosed

In 18706/josm:

Fix #22817: Don't delete layer with changes and a non-normal upload policy (patch by gaben, modified)

Patch modifications are as follows:

  • A non-regression test
  • Account for UploadPolicy.BLOCKED causing requiresUploadToServer to return false.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.