Ticket #20598: 20598.2.patch

File 20598.2.patch, 3.7 KB (added by taylor.smock, 5 years ago)

Add method to indicate that a temporary copy has been updated, fix broken tests

  • src/org/openstreetmap/josm/data/ImageData.java

     
    5959        if (data != null) {
    6060            Collections.sort(data);
    6161            this.data = data;
     62            this.data.forEach(image -> image.setDataSet(this));
    6263        } else {
    6364            this.data = new ArrayList<>();
    6465        }
    6566        this.geoImages.addAll(this.data);
    66         data.forEach(image -> image.setDataSet(this));
    6767        selectedImagesIndex.add(-1);
    6868    }
    6969
  • src/org/openstreetmap/josm/data/gpx/GpxImageCorrelation.java

     
    240240                    }
    241241                    curTmp.setGpsTime(new Date(curImg.getExifTime().getTime() - offset));
    242242                    curTmp.flagNewGpsData();
     243                    curImg.tmpUpdated();
     244
    243245                    ret++;
    244246                }
    245247                i--;
     
    264266                    }
    265267                    curTmp.setGpsTime(new Date(curImg.getExifTime().getTime() - offset));
    266268                    curTmp.flagNewGpsData();
     269                    curImg.tmpUpdated();
    267270
    268271                    ret++;
    269272                }
  • src/org/openstreetmap/josm/data/gpx/GpxImageEntry.java

     
    508508            isNewGpsData = tmp.isNewGpsData;
    509509            tmp = null;
    510510        }
     511        tmpUpdated();
    511512    }
    512513
    513514    /**
     
    516517     */
    517518    public void discardTmp() {
    518519        tmp = null;
     520        tmpUpdated();
    519521    }
    520522
    521523    /**
     
    548550        isNewGpsData = true;
    549551   }
    550552
     553    /**
     554     * Indicate that the temporary copy has been updated. Mostly used to prevent UI issues.
     555     * By default, this is a no-op. Override when needed in subclasses.
     556     * @since xxx
     557     */
     558    protected void tmpUpdated() {
     559        // No-op by default
     560    }
     561
    551562    @Override
    552563    public BBox getBBox() {
    553564        // new BBox(LatLon) is null safe.
  • src/org/openstreetmap/josm/gui/layer/geoimage/ImageEntry.java

     
    3232    public ImageEntry(ImageEntry other) {
    3333        super(other);
    3434        thumbnail = other.thumbnail;
     35        dataSet = other.dataSet;
    3536    }
    3637
    3738    /**
     
    7778    }
    7879
    7980    @Override
    80     public void applyTmp() {
    81         super.applyTmp();
     81    protected void tmpUpdated() {
     82        super.tmpUpdated();
    8283        if (this.dataSet != null) {
    8384            this.dataSet.fireNodeMoved(this);
    8485        }
    8586    }
    8687
    87     @Override
    88     public void discardTmp() {
    89         super.discardTmp();
    90         if (this.dataSet != null) {
    91             this.dataSet.fireNodeMoved(this);
    92         }
    93     }
    94 
    9588    /**
    9689     * Set the dataset for this image
    9790     * @param imageData The dataset
     
    122115        if (!super.equals(obj) || getClass() != obj.getClass())
    123116            return false;
    124117        ImageEntry other = (ImageEntry) obj;
    125         return Objects.equals(thumbnail, other.thumbnail);
     118        return Objects.equals(thumbnail, other.thumbnail) && Objects.equals(dataSet, other.dataSet);
    126119    }
    127120}