Changeset 8646 in josm for trunk/src


Ignore:
Timestamp:
2015-08-07T21:02:00+02:00 (9 years ago)
Author:
wiktorn
Message:

Move listeners notification outside synchronized sections.

Addresses: #11689

File:
1 edited

Legend:

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

    r8642 r8646  
    417417            }
    418418
    419             fireLayerAdded(layer);
    420419            if (isOsmDataLayer) {
    421420                ((OsmDataLayer) layer).addLayerStateChangeListener(this);
    422421            }
    423             onActiveEditLayerChanged(oldActiveLayer, oldEditLayer, listenersToFire);
     422
    424423            layer.addPropertyChangeListener(this);
    425424            Main.addProjectionChangeListener(layer);
    426425            AudioPlayer.reset();
    427426        }
     427        fireLayerAdded(layer);
     428        onActiveEditLayerChanged(oldActiveLayer, oldEditLayer, listenersToFire);
     429
    428430        if (!listenersToFire.isEmpty()) {
    429431            repaint();
     
    518520            layers.remove(layer);
    519521            Main.removeProjectionChangeListener(layer);
    520 
    521             onActiveEditLayerChanged(oldActiveLayer, oldEditLayer, listenersToFire);
    522             fireLayerRemoved(layer);
    523522            layer.removePropertyChangeListener(this);
    524523            layer.destroy();
    525524            AudioPlayer.reset();
    526525        }
     526        onActiveEditLayerChanged(oldActiveLayer, oldEditLayer, listenersToFire);
     527        fireLayerRemoved(layer);
     528
    527529        repaint();
    528530    }
     
    576578            }
    577579            listenersToFire = setEditLayer(layers);
    578             onActiveEditLayerChanged(oldActiveLayer, oldEditLayer, listenersToFire);
    579580            AudioPlayer.reset();
    580581        }
     582        onActiveEditLayerChanged(oldActiveLayer, oldEditLayer, listenersToFire);
     583
    581584        repaint();
    582585    }
     
    922925    public void setActiveLayer(Layer layer) {
    923926        EnumSet<LayerListenerType> listenersToFire;
    924 
    925         synchronized (layers) {
    926             Layer oldActiveLayer = activeLayer;
    927             OsmDataLayer oldEditLayer = editLayer;
     927        Layer oldActiveLayer;
     928        OsmDataLayer oldEditLayer;
     929
     930        synchronized (layers) {
     931            oldActiveLayer = activeLayer;
     932            oldEditLayer = editLayer;
    928933            listenersToFire = setActiveLayer(layer, true);
    929             onActiveEditLayerChanged(oldActiveLayer, oldEditLayer, listenersToFire);
    930         }
     934        }
     935        onActiveEditLayerChanged(oldActiveLayer, oldEditLayer, listenersToFire);
     936
    931937        repaint();
    932938    }
Note: See TracChangeset for help on using the changeset viewer.