Opened 20 months ago
Closed 19 months ago
#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 )
What steps will reproduce the problem?
- Download new data
- Make some changes
- Set "discourage upload" on the layer
- 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 , 20 months ago
Priority: | normal → critical |
---|
follow-up: 4 comment:2 by , 20 months ago
Description: | modified (diff) |
---|---|
Milestone: | → 23.03 |
Priority: | critical → major |
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
112 112 public static boolean saveUnsavedModifications(Iterable<? extends Layer> selectedLayers, Reason reason) { 113 113 if (!GraphicsEnvironment.isHeadless()) { 114 114 SaveLayersDialog dialog = new SaveLayersDialog(MainApplication.getMainFrame()); 115 List<AbstractModifiableLayer> layersWithUn modifiedChanges = new ArrayList<>();115 List<AbstractModifiableLayer> layersWithUnsavedChanges = new ArrayList<>(); 116 116 for (Layer l: selectedLayers) { 117 117 if (!(l instanceof AbstractModifiableLayer)) { 118 118 continue; … … 121 121 if (odl.isModified() && 122 122 ((!odl.isSavable() && !odl.isUploadable()) || 123 123 odl.requiresSaveToFile() || 124 (odl.requiresUploadToServer() && !odl.isUploadDiscouraged()))) {125 layersWithUn modifiedChanges.add(odl);124 odl.requiresUploadToServer())) { 125 layersWithUnsavedChanges.add(odl); 126 126 } 127 127 } 128 128 dialog.prepareForSavingAndUpdatingLayers(reason); 129 if (!layersWithUn modifiedChanges.isEmpty()) {130 dialog.getModel().populate(layersWithUn modifiedChanges);129 if (!layersWithUnsavedChanges.isEmpty()) { 130 dialog.getModel().populate(layersWithUnsavedChanges); 131 131 dialog.setVisible(true); 132 132 switch(dialog.getUserAction()) { 133 133 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:4 by , 19 months ago
Replying to gaben:
The
upload=never
option is not affected as in that case theisUploadable()
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".
With current behavior, you can loose all you work, e.g. a private file of all you mushroom spots.