Changeset 35767 in osm


Ignore:
Timestamp:
2021-05-24T20:23:08+02:00 (3 years ago)
Author:
holgermappt
Message:

Remove image data update listener only if it was registered, see #josm20893

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/photoadjust/src/org/openstreetmap/josm/plugins/photoadjust/PhotoPropertyEditor.java

    r35600 r35767  
    6767     */
    6868    private static class PropertyEditorAction extends JosmAction implements LayerChangeListener, ImageDataUpdateListener {
     69        boolean imgDataUpdLstReg = false;
     70
    6971        public PropertyEditorAction() {
    7072            super(tr("Edit photo GPS data"),  // String name
     
    135137            if (layer instanceof GeoImageLayer) {
    136138                ((GeoImageLayer) layer).getImageData().addImageDataUpdateListener(this);
     139                imgDataUpdLstReg = true;
    137140            }
    138141        }
     
    143146
    144147            if (layer instanceof GeoImageLayer) {
    145                 ((GeoImageLayer) layer).getImageData().removeImageDataUpdateListener(this);
     148                // In some combinations the listener might not be registered,
     149                // e.g. if the plugin was added while the geo image layer
     150                // existed and then the layer is removed.
     151                if (imgDataUpdLstReg) {
     152                    ((GeoImageLayer) layer).getImageData().removeImageDataUpdateListener(this);
     153                    imgDataUpdLstReg = false;
     154                }
    146155            }
    147156            this.updateEnabledState();
Note: See TracChangeset for help on using the changeset viewer.