Changeset 18947 in josm


Ignore:
Timestamp:
2024-01-19T14:24:48+01:00 (10 months ago)
Author:
GerdP
Message:

fix memory leak, ImgDisplay.destroy() was only called when at least one image was viewed

Location:
trunk/src/org/openstreetmap/josm/gui/layer/geoimage
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageDisplay.java

    r18871 r18947  
    117117    private UpdateImageThread updateImageThreadInstance;
    118118
     119    private boolean destroyed;
     120
    119121    private class UpdateImageThread extends Thread {
    120122        private boolean restart;
     
    620622    @Override
    621623    public void destroy() {
    622         removeMouseListener(imgMouseListener);
    623         removeMouseWheelListener(imgMouseListener);
    624         removeMouseMotionListener(imgMouseListener);
    625         Config.getPref().removePreferenceChangeListener(this);
    626         if (imageProcessor instanceof ImageryFilterSettings) {
    627             ((ImageryFilterSettings) imageProcessor).removeFilterChangeListener(this);
    628         }
     624        if (!destroyed) {
     625            removeMouseListener(imgMouseListener);
     626            removeMouseWheelListener(imgMouseListener);
     627            removeMouseMotionListener(imgMouseListener);
     628            Config.getPref().removePreferenceChangeListener(this);
     629            if (imageProcessor instanceof ImageryFilterSettings) {
     630                ((ImageryFilterSettings) imageProcessor).removeFilterChangeListener(this);
     631            }
     632        }
     633        destroyed = true;
    629634    }
    630635
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageViewerDialog.java

    r18946 r18947  
    411411        cancelLoadingImage();
    412412        super.destroy();
     413        // make sure that Image Display is destroyed here, it might not be a component
     414        imgDisplay.destroy();
    413415        // Ensure that this dialog is removed from memory
    414416        destroyInstance();
Note: See TracChangeset for help on using the changeset viewer.