Changeset 6936 in josm


Ignore:
Timestamp:
2014-03-28T19:53:24+01:00 (10 years ago)
Author:
Don-vip
Message:

fix #9870 - exception when trying to view history of new nodes from their parent way history dialog

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/history/NodeListViewer.java

    r6883 r6936  
    276276
    277277        public void updateEnabledState() {
    278             setEnabled(primitiveId != null && primitiveId.getUniqueId() > 0);
     278            setEnabled(primitiveId != null && !primitiveId.isNew());
    279279        }
    280280    }
     
    314314            if(row <= 0) return;
    315315            PrimitiveId pid = primitiveIdAtRow(table.getModel(), row);
    316             if (pid == null)
     316            if (pid == null || pid.isNew())
    317317                return;
    318318            showHistoryAction.setPrimitiveId(pid);
  • trunk/src/org/openstreetmap/josm/io/OsmReader.java

    r6650 r6936  
    448448            }
    449449            if (ds.getVersion().equals("0.6")){
    450                 if (version <= 0 && current.getUniqueId() > 0) {
     450                if (version <= 0 && !current.isNew()) {
    451451                    throwException(tr("Illegal value for attribute ''version'' on OSM primitive with ID {0}. Got {1}.", Long.toString(current.getUniqueId()), versionString));
    452                 } else if (version < 0 && current.getUniqueId() <= 0) {
     452                } else if (version < 0 && current.isNew()) {
    453453                    Main.warn(tr("Normalizing value of attribute ''version'' of element {0} to {2}, API version is ''{3}''. Got {1}.", current.getUniqueId(), version, 0, "0.6"));
    454454                    version = 0;
    455455                }
    456456            } else if (ds.getVersion().equals("0.5")) {
    457                 if (version <= 0 && current.getUniqueId() > 0) {
     457                if (version <= 0 && !current.isNew()) {
    458458                    Main.warn(tr("Normalizing value of attribute ''version'' of element {0} to {2}, API version is ''{3}''. Got {1}.", current.getUniqueId(), version, 1, "0.5"));
    459459                    version = 1;
    460                 } else if (version < 0 && current.getUniqueId() <= 0) {
     460                } else if (version < 0 && current.isNew()) {
    461461                    Main.warn(tr("Normalizing value of attribute ''version'' of element {0} to {2}, API version is ''{3}''. Got {1}.", current.getUniqueId(), version, 0, "0.5"));
    462462                    version = 0;
     
    469469            // version expected for OSM primitives with an id assigned by the server (id > 0), since API 0.6
    470470            //
    471             if (current.getUniqueId() > 0 && ds.getVersion() != null && ds.getVersion().equals("0.6")) {
     471            if (!current.isNew() && ds.getVersion() != null && ds.getVersion().equals("0.6")) {
    472472                throwException(tr("Missing attribute ''version'' on OSM primitive with ID {0}.", Long.toString(current.getUniqueId())));
    473             } else if (current.getUniqueId() > 0 && ds.getVersion() != null && ds.getVersion().equals("0.5")) {
     473            } else if (!current.isNew() && ds.getVersion() != null && ds.getVersion().equals("0.5")) {
    474474                // default version in 0.5 files for existing primitives
    475475                Main.warn(tr("Normalizing value of attribute ''version'' of element {0} to {2}, API version is ''{3}''. Got {1}.", current.getUniqueId(), version, 1, "0.5"));
    476476                version= 1;
    477             } else if (current.getUniqueId() <= 0 && ds.getVersion() != null && ds.getVersion().equals("0.5")) {
     477            } else if (current.isNew() && ds.getVersion() != null && ds.getVersion().equals("0.5")) {
    478478                // default version in 0.5 files for new primitives, no warning necessary. This is
    479479                // (was) legal in API 0.5
     
    500500                current.setChangesetId(Integer.parseInt(v));
    501501            } catch(NumberFormatException e) {
    502                 if (current.getUniqueId() <= 0) {
     502                if (current.isNew()) {
    503503                    // for a new primitive we just log a warning
    504504                    Main.info(tr("Illegal value for attribute ''changeset'' on new object {1}. Got {0}. Resetting to 0.", v, current.getUniqueId()));
     
    510510            }
    511511            if (current.getChangesetId() <=0) {
    512                 if (current.getUniqueId() <= 0) {
     512                if (current.isNew()) {
    513513                    // for a new primitive we just log a warning
    514514                    Main.info(tr("Illegal value for attribute ''changeset'' on new object {1}. Got {0}. Resetting to 0.", v, current.getUniqueId()));
Note: See TracChangeset for help on using the changeset viewer.