Changeset 5448 in josm for trunk/src


Ignore:
Timestamp:
2012-08-15T17:11:43+02:00 (12 years ago)
Author:
Don-vip
Message:

Prevents MapView from being repainted multiple times when adding the first active layer

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

Legend:

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

    r5152 r5448  
    627627            }
    628628        }
    629         if (!modeChanged && mapMode != null) {
    630             // Let mapmodes know about new active layer
    631             mapMode.exitMode();
    632             mapMode.enterMode();
    633         }
    634         // invalidate repaint cache
    635         Main.map.mapView.preferenceChanged(null);
     629        // if this is really a change (and not the first active layer)
     630        if (oldLayer != null) {
     631            if (!modeChanged && mapMode != null) {
     632                // Let mapmodes know about new active layer
     633                mapMode.exitMode();
     634                mapMode.enterMode();
     635            }
     636            // invalidate repaint cache
     637            Main.map.mapView.preferenceChanged(null);
     638        }
    636639
    637640        // After all listeners notice new layer, some buttons will be disabled/enabled
  • trunk/src/org/openstreetmap/josm/gui/MapView.java

    r5407 r5448  
    319319        }
    320320        fireLayerAdded(layer);
    321         if (layer instanceof OsmDataLayer || activeLayer == null) {
     321        boolean callSetActiveLayer = layer instanceof OsmDataLayer || activeLayer == null;
     322        if (callSetActiveLayer) {
    322323            // autoselect the new layer
    323             setActiveLayer(layer);
     324            setActiveLayer(layer); // also repaints this MapView
    324325        }
    325326        layer.addPropertyChangeListener(this);
    326327        Main.addProjectionChangeListener(layer);
    327328        AudioPlayer.reset();
    328         repaint();
     329        if (!callSetActiveLayer) {
     330            repaint();
     331        }
    329332    }
    330333
Note: See TracChangeset for help on using the changeset viewer.