Changeset 10474 in josm


Ignore:
Timestamp:
2016-06-24T07:59:21+02:00 (5 years ago)
Author:
wiktorn
Message:

Use WarningLayerPainter as a temporary painter for layers during initialization

Patch by: michael2402 - gsoc-core
Closes: #13024

File:
1 edited

Legend:

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

    r10458 r10474  
    319319
    320320    /**
     321     * A layer painter that issues a warning when being called.
     322     * @author Michael Zangl
     323     * @since 10474
     324     */
     325    private static class WarningLayerPainter implements LayerPainter {
     326        boolean warningPrinted = false;
     327        private Layer layer;
     328
     329        public WarningLayerPainter(Layer layer) {
     330            this.layer = layer;
     331        }
     332
     333        @Override
     334        public void paint(MapViewGraphics graphics) {
     335            if (!warningPrinted) {
     336                Main.debug("A layer triggered a repaint while being added: " + layer);
     337                warningPrinted = true;
     338            }
     339        }
     340
     341        @Override
     342        public void detachFromMapView(MapViewEvent event) {
     343            // ignored
     344        }
     345    }
     346
     347    /**
    321348     * Removes a layer change listener
    322349     * <p>
     
    603630        try {
    604631            Layer layer = e.getAddedLayer();
     632            registeredLayers.put(layer, new WarningLayerPainter(layer));
     633            // Layers may trigger a redraw during this call if they open dialogs.
    605634            registeredLayers.put(layer, layer.attachToMapView(new MapViewEvent(this, false)));
    606635
Note: See TracChangeset for help on using the changeset viewer.