#23648 closed defect (fixed)
[patch] Not possible to save a layer after marked as "Discourage upload"
Reported by: | gaben | Owned by: | team |
---|---|---|---|
Priority: | normal | Milestone: | 24.06 |
Component: | Core | Version: | |
Keywords: | template_report upload discourage | Cc: |
Description (last modified by )
What steps will reproduce the problem?
- Have a new layer with some data
- Save it
- Mark it as "Discourage upload"
- Try to save it again
What is the expected result?
It's possible to save the layer OR the upload attribute automatically propagated to the file without user intervention.
What happens instead?
The save button greyed out. To save the upload=false attribute to the file, I need to make a change to the dataset, then the save button will be available and the attribute will be saved to the file.
Please provide any additional information below. Attach a screenshot if possible.
It was modified during #23506, #23408 and #22817.
Relative:URL: ^/trunk Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b Last:Changed Date: 2024-04-27 10:24:46 +0200 (Sat, 27 Apr 2024) Revision:19064 Build-Date:2024-04-28 01:31:14 URL:https://josm.openstreetmap.de/svn/trunk
Attachments (4)
Change History (32)
comment:1 by , 9 months ago
Description: | modified (diff) |
---|
comment:2 by , 9 months ago
comment:3 by , 9 months ago
BTW: the save action is still available in the context menu of the layer side window.
Proposed solution:
-
src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
1195 1195 if (data.getUploadPolicy() != UploadPolicy.BLOCKED && 1196 1196 (uploadDiscouraged ^ isUploadDiscouraged())) { 1197 1197 data.setUploadPolicy(uploadDiscouraged ? UploadPolicy.DISCOURAGED : UploadPolicy.NORMAL); 1198 setRequiresSaveToFile(true); 1198 1199 for (LayerStateChangeListener l : layerStateChangeListeners) { 1199 1200 l.uploadDiscouragedChanged(this, uploadDiscouraged); 1200 1201 }
comment:4 by , 8 months ago
Summary: | Not possible to save a layer after marked as "Discourage upload" → [patch] Not possible to save a layer after marked as "Discourage upload" |
---|
Didn't test the patch yet, just putting the existence in the title.
comment:5 by , 8 months ago
Milestone: | → 24.06 |
---|
comment:7 by , 8 months ago
I don't know, probably yes, but I have to check and don't have much time for investigation, unfortunately :(
Setting it to true all the time looks suspicious to me. Before the preconditions cleanup, it was working fine, and this part wasn't touched. There is an isSavable()
method for layers, which should say yes, and the handling code should respect it. If I have to guess, it goes wrong somewhere here.
comment:8 by , 8 months ago
Question is why Save
is disabled at all. In my eyes it should always be possible to save the layer to file again, even if that would just overwrite the existing file with the same data.
Example case: I save to work.osm and use a command line or file manager to move that file somewhere else to experiment with the data.
JOSM.
File->Save is disabled, the right click on the layer work.osm shows an enabled Save function.
Seems this behaviour was introduced for #12669
by , 8 months ago
Attachment: | 23648.patch added |
---|
comment:9 by , 8 months ago
The patch is still incomplete. I think there's one more issue: The ToggleUploadDiscouragedLayerAction
really toggles the uploadDiscouraged
flag, but the action text says tr("Discourage upload")
and the icon is always the same.
I think the text should be changed to tr("Encourage/Discourage upload")
and a notification should be shown when the state is toggled.
by , 8 months ago
Attachment: | 23648-2.patch added |
---|
follow-up: 11 comment:10 by , 8 months ago
The patch introduces these changes:
- enable Edit->Save if layer is saveable (remove complex logic)
- show notification when
uploadDiscouraged
is toggled - set requiresSaveToFile flag when the
uploadDiscouraged
is toggled - change action text to
tr("Discourage/Encourage upload")
One small problem: If you toggle the uploadDiscouraged
flag twice there is not really a need to save to file, but we have the same issue when you modify data and then undo all changes.
comment:11 by , 8 months ago
Summary: | [patch] Not possible to save a layer after marked as "Discourage upload" → [WIP patch] Not possible to save a layer after marked as "Discourage upload" |
---|
One small problem: If you toggle the
uploadDiscouraged
flag twice there is not really a need to save to file, but we have the same issue when you modify data and then undo all changes.
I think the requiresSaveToFile
property is there for this reason. So there should be a better way, which I don't know (yet).
Now, if the layer is savable (yes?) and requires saving to the file (yes?) why cannot it save?
I just noticed a weird behaviour: after I save the file in step 2, the save button is still active and I can save it again.
follow-up: 13 comment:12 by , 8 months ago
Did you try with 23648.2.patch?
I think the requiresSaveToFile property is there for this reason. So there should be a better way, which I don't know (yet).
The property is set when either the data or the meta data like the uploadDiscouraged
flag is changed. I see no need to really check if the content of an existing file would be changed or not.
I just noticed a weird behaviour: after I save the file in step 2, the save button is still active and I can save it again.
That's exactly what I want. See comment:8. The layer action Save
is also always enabled.
follow-up: 17 comment:13 by , 8 months ago
Did you try with 23648.2.patch?
Yes.
The property is set when either the data or the meta data like the
uploadDiscouraged
flag is changed. I see no need to really check if the content of an existing file would be changed or not.
There is a * mark in the window title if there are any unsaved changes, like * Java OpenStreetMap Editor
. With the patch it is becomes confusing.
I just noticed a weird behaviour: after I save the file in step 2, the save button is still active and I can save it again.
That's exactly what I want. See comment:8. The layer action
Save
is also always enabled.
This behaviour is without the patch, please try it out. I meant to say, it is possible to save exactly twice in this case, but only after the save. There is something wrong deeper.
comment:15 by , 8 months ago
:(
When I mark a layer as discourage upload, I'd like to save it exactly once as it was working previous releases.
(Disabling the save adds extra information that anything is open is actually saved.)
follow-up: 19 comment:17 by , 7 months ago
Replying to gaben:
This behaviour is without the patch, please try it out. I meant to say, it is possible to save exactly twice in this case, but only after the save. There is something wrong deeper.
I was not able to reproduce this.
comment:18 by , 7 months ago
With the patch it is becomes confusing.
It took a while but now I understand why you think the enabled Save could be confusing. You probably use the grayed icon in the main menu as an indicator that the file was not changed? That's in fact a good reason to keep the old (in my eyes wrong) behaviour.
I'll have a closer look at the code in SaveAction.updateEnabledState ()
comment:19 by , 7 months ago
Replying to GerdP:
Replying to gaben:
This behaviour is without the patch, please try it out. I meant to say, it is possible to save exactly twice in this case, but only after the save. There is something wrong deeper.
I was not able to reproduce this.
Now I found out how to reproduce:
1) Have a new layer with some data
2) Save it with File->Save As
by , 7 months ago
Attachment: | 23648-3.patch added |
---|
comment:20 by , 7 months ago
23648-3.patch fixes the problem with "Save As". I've moved the complex code to SaveActionBase.updateEnabledState ()
as this is also called by SaveAsAction
. With the unpatched code SaveAction.updateEnabledState ()
was not called when "Save As" was used.
I'm not sure if the test should use this instanceof SaveAction
or simply check the quiet
flag.
Maybe I should also add the final modifier to SaveActionBase.updateEnabledState ()
?
comment:21 by , 7 months ago
Thank you for working on it, and I'm sorry if I wasn't clear.
This v3 patch is better, but I still see an issue. The asterisk remains there after the file is saved. To reproduce:
Have a new layer with some dataSave it with File → Save AsCheck the window title and layer name.
Edit: I just checked without the patch. It's there, so I think it's a new bug, yay!
by , 7 months ago
Attachment: | asterisk.png added |
---|
comment:22 by , 7 months ago
I think the asterisk tells you that data can be uploaded and that the upload is not discouraged?
comment:23 by , 7 months ago
Summary: | [WIP patch] Not possible to save a layer after marked as "Discourage upload" → [patch] Not possible to save a layer after marked as "Discourage upload" |
---|
Ah, it's defined by isDirty():
/** * Determines if this layer is "dirty", i.e. requires save or upload * @return if this layer is "dirty" * @since 18287 */ public boolean isDirty() { // Override if needed return requiresSaveToFile() || (requiresUploadToServer() && !isUploadDiscouraged()); }
and my picture shows an upload encouraged state. Sigh. Everything is alright. Sorry, I'm tired.
The last remark: I don't like the "Discourage/Encourage upload" string change, as usually there is no sentence like
- "(x) Enable/disable feature y", just
- "(x) Enable feature y"
follow-up: 26 comment:24 by , 7 months ago
The action toggles the state. I found no similar case in JOSM as an example. Do you have one?
comment:26 by , 7 months ago
The action toggles the state. I found no similar case in JOSM as an example. Do you have one?
I don't, it's unique stuff. Thanks btw!
comment:27 by , 7 months ago
You're welcome! The toggle action confused me as well in the past, I just needed a push to look at the details ;)
comment:28 by , 7 months ago
Let me know if you have something else in your mind, maybe we can cooperate ;)
Hit the same problem in the last days.
I wouldn't want that.