Changeset 14556 in josm


Ignore:
Timestamp:
2018-12-12T15:59:43+01:00 (2 months ago)
Author:
GerdP
Message:

see #17040 more cleanup in OsmDataLayer.destroy()

  • remove DatasetListeners previously added
  • clear recentRelations
  • don't call Dataset.clear() here because there may still be active listeners
  • call DataSet.clear in LayerManager after all listeners are removed

Hope this doesn't break unit tests, can't test on my machine.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/DataSet.java

    r14247 r14556  
    10361036    @Override
    10371037    public void clear() {
     1038        //TODO: Why can't we clear a dataset that is locked?
     1039        //TODO: Report listeners that are still active (should be none)
    10381040        checkModifiable();
    10391041        beginUpdate();
  • trunk/src/org/openstreetmap/josm/gui/layer/LayerManager.java

    r12630 r14556  
    1212import java.util.function.Consumer;
    1313
     14import org.openstreetmap.josm.data.osm.DataSet;
    1415import org.openstreetmap.josm.gui.MainApplication;
    1516import org.openstreetmap.josm.gui.util.GuiHelper;
     
    478479            }
    479480        }
     481        if (layer instanceof OsmDataLayer) {
     482            DataSet data = ((OsmDataLayer)layer).data;
     483            if (data != null && !data.isLocked())
     484                data.clear();
     485        }
    480486        return e.scheduleForRemoval;
    481487    }
  • trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r14537 r14556  
    359359     */
    360360    public final DataSet data;
     361    private DataSetListenerAdapter dataSetListenerAdapter;
    361362
    362363    /**
     
    412413        this.data = data;
    413414        this.data.setName(name);
     415        this.dataSetListenerAdapter = new DataSetListenerAdapter(this);
    414416        this.setAssociatedFile(associatedFile);
    415         data.addDataSetListener(new DataSetListenerAdapter(this));
     417        data.addDataSetListener(dataSetListenerAdapter);
    416418        data.addDataSetListener(MultipolygonCache.getInstance());
    417419        data.addHighlightUpdateListener(this);
     
    10591061        data.removeSelectionListener(this);
    10601062        data.removeHighlightUpdateListener(this);
     1063        data.removeDataSetListener(dataSetListenerAdapter);
     1064        data.removeDataSetListener(MultipolygonCache.getInstance());
    10611065        removeClipboardDataFor(this);
    1062         if (!data.isLocked()) {
    1063             data.clear();
    1064         }
     1066        recentRelations.clear();
    10651067    }
    10661068
Note: See TracChangeset for help on using the changeset viewer.