Changeset 10412 in josm for trunk/src/org
- Timestamp:
- 2016-06-17T23:50:27+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r10400 r10412 83 83 import org.openstreetmap.josm.gui.MapFrame; 84 84 import org.openstreetmap.josm.gui.MapFrameListener; 85 import org.openstreetmap.josm.gui.MapView; 85 86 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; 86 87 import org.openstreetmap.josm.gui.help.HelpUtil; … … 526 527 Main.map = map; 527 528 529 // Notify map frame listeners, mostly plugins. 530 if ((map == null) == (old == null)) { 531 Main.warn("Replacing the map frame. This is not expected by some plugins and should not happen."); 532 } 528 533 for (MapFrameListener listener : mapFrameListeners) { 534 MapView.fireDeprecatedListenerOnAdd = true; 529 535 listener.mapFrameInitialized(old, map); 536 MapView.fireDeprecatedListenerOnAdd = false; 530 537 } 531 538 if (map == null && currentProgressMonitor != null) { -
trunk/src/org/openstreetmap/josm/gui/MapView.java
r10401 r10412 375 375 @Deprecated 376 376 public static void addLayerChangeListener(LayerChangeListener listener) { 377 addLayerChangeListener(listener, false); 377 if (fireDeprecatedListenerOnAdd) { 378 Main.warn("Plugin seems to be adding listener during mapFrameInitialized(): " + BugReport.getCallingMethod(2) 379 + ". Layer listeners should be set on plugin load."); 380 } 381 addLayerChangeListener(listener, fireDeprecatedListenerOnAdd); 378 382 } 379 383 … … 391 395 public static void addLayerChangeListener(LayerChangeListener listener, boolean initialFire) { 392 396 if (listener != null) { 393 initialFire = initialFire && Main.isDisplayingMapView();397 initialFire = initialFire && (Main.isDisplayingMapView() || fireDeprecatedListenerOnAdd); 394 398 395 399 LayerChangeAdapter adapter = new LayerChangeAdapter(listener, initialFire); 396 Main.getLayerManager().addLayerChangeListener(adapter, false);400 Main.getLayerManager().addLayerChangeListener(adapter, initialFire); 397 401 if (initialFire) { 398 402 Main.getLayerManager().addAndFireActiveLayerChangeListener(adapter); … … 438 442 addEditLayerChangeListener(listener, false); 439 443 } 444 445 446 /** 447 * Temporary. To be removed as soon as the {@link LayerChangeListener}s are removed. 448 * <p> 449 * Some plugins add their listeners in {@link Main#setMapFrame(MapFrame)}. This method is now called just after the first layer was added to 450 * the layer manager. So that listener would not receive the addition of the first layer. As long as this field is set, we fake an add call 451 * to that listener when it is added to immitate the old behaviour. You should not access it from anywhere else. 452 */ 453 public static boolean fireDeprecatedListenerOnAdd; 440 454 441 455 public boolean viewportFollowing; -
trunk/src/org/openstreetmap/josm/tools/bugreport/BugReport.java
r10375 r10412 63 63 * @return The method name. 64 64 */ 65 static String getCallingMethod(int offset) {65 public static String getCallingMethod(int offset) { 66 66 StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); 67 67 String className = BugReport.class.getName();
Note:
See TracChangeset
for help on using the changeset viewer.