Modify

Opened 15 months ago

Closed 15 months ago

Last modified 15 months ago

#7504 closed defect (fixed)

[Patch] Indentation/Block mismatch – maybe cause for wrong “modified” warnings (or * in window title)?

Reported by: xeen Owned by: team
Priority: minor Component: Core
Version: Keywords:
Cc: joshdoe, bastiK

Description

Have a look at source:josm/trunk/src/org/openstreetmap/josm/command/ChangePropertyCommand.java#L131:

for (OsmPrimitive osm : objects) {
    boolean modified = false;
     // loop over all tags
    for (Map.Entry<String, String> tag : this.tags.entrySet()) {
        String oldVal = osm.get(tag.getKey());
        String newVal = tag.getValue();
        if (newVal == null || newVal.isEmpty()) {
            if (oldVal != null) {
                osm.remove(tag.getKey());
                modified = true;
            }
        }
        else if (oldVal == null || !newVal.equals(oldVal))
            osm.put(tag.getKey(), newVal);
            modified = true;                                      // this is line 131
    }
    if (modified)
        osm.setModified(true);
}

As far as I can tell this marks all objects as modified which have at least one tag. From the logic of that code I would deduce that the identation is correct, but the braces around the else-if clause are missing.

Since this might introduce hard-to-catch bugs, I’d like someone else to have a look at this. I believe this was introduced in r4773.

Attachments (1)

7504.patch (1.5 KB) - added by xeen 15 months ago.
Appears you are right and the additional modified work is superfluous. Suggested patch.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 15 months ago by bastiK

Yes, looks like the braces are missing. I think it doesn't matter because init makes sure that only "modified" objects are taken into account.

Changed 15 months ago by xeen

Appears you are right and the additional modified work is superfluous. Suggested patch.

comment:2 Changed 15 months ago by skyper

  • Summary changed from Indentation/Block mismatch – maybe cause for wrong “modified” warnings (or * in window title)? to [Patch] Indentation/Block mismatch – maybe cause for wrong “modified” warnings (or * in window title)?

comment:3 Changed 15 months ago by simon04

bastiK, xeen: Shall this patch be applied?

comment:4 Changed 15 months ago by bastiK

I see nothing wrong with this patch.

comment:5 Changed 15 months ago by xeen

  • Resolution set to fixed
  • Status changed from new to closed

In 5143/josm:

fix #7504 -- Remove superfluous check

comment:6 Changed 15 months ago by xeen

thanks, had this almost forgotten…

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed .
as The resolution will be set. Next status will be 'closed'.
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.