Changeset 10476 in josm


Ignore:
Timestamp:
2016-06-24T08:37:08+02:00 (8 years ago)
Author:
Don-vip
Message:

fix #13046 - Warn if layer calls removeLayer during attachToMapView (patch by michael2402) - gsoc-core

File:
1 edited

Legend:

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

    r10474 r10476  
    632632            registeredLayers.put(layer, new WarningLayerPainter(layer));
    633633            // Layers may trigger a redraw during this call if they open dialogs.
    634             registeredLayers.put(layer, layer.attachToMapView(new MapViewEvent(this, false)));
    635 
    636             ProjectionBounds viewProjectionBounds = layer.getViewProjectionBounds();
    637             if (viewProjectionBounds != null) {
    638                 scheduleZoomTo(new ViewportData(viewProjectionBounds));
    639             }
    640 
    641             layer.addPropertyChangeListener(this);
    642             Main.addProjectionChangeListener(layer);
    643             invalidatedListener.addTo(layer);
    644             AudioPlayer.reset();
    645 
    646             repaint();
     634            LayerPainter painter = layer.attachToMapView(new MapViewEvent(this, false));
     635            if (!registeredLayers.containsKey(layer)) {
     636                // The layer may have removed itself during attachToMapView()
     637                Main.warn("Layer was removed during attachToMapView()");
     638            } else {
     639                registeredLayers.put(layer, painter);
     640
     641                ProjectionBounds viewProjectionBounds = layer.getViewProjectionBounds();
     642                if (viewProjectionBounds != null) {
     643                    scheduleZoomTo(new ViewportData(viewProjectionBounds));
     644                }
     645
     646                layer.addPropertyChangeListener(this);
     647                Main.addProjectionChangeListener(layer);
     648                invalidatedListener.addTo(layer);
     649                AudioPlayer.reset();
     650
     651                repaint();
     652            }
    647653        } catch (RuntimeException t) {
    648654            throw BugReport.intercept(t).put("layer", e.getAddedLayer());
Note: See TracChangeset for help on using the changeset viewer.