diff --git a/src/org/openstreetmap/josm/Main.java b/src/org/openstreetmap/josm/Main.java
index 278c952..99dd688 100644
|
a
|
b
|
import org.openstreetmap.josm.gui.MainApplication.Option;
|
| 82 | 82 | import org.openstreetmap.josm.gui.MainMenu; |
| 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; |
| 87 | 88 | import org.openstreetmap.josm.gui.io.SaveLayersDialog; |
| … |
… |
public abstract class Main {
|
| 525 | 526 | |
| 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) { |
| 532 | 539 | currentProgressMonitor.showForegroundDialog(); |
diff --git a/src/org/openstreetmap/josm/gui/MapView.java b/src/org/openstreetmap/josm/gui/MapView.java
index 67a62e0..1415463 100644
|
a
|
b
|
LayerManager.LayerChangeListener, MainLayerManager.ActiveLayerChangeListener {
|
| 374 | 374 | */ |
| 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 | |
| 380 | 384 | /** |
| … |
… |
LayerManager.LayerChangeListener, MainLayerManager.ActiveLayerChangeListener {
|
| 390 | 394 | @Deprecated |
| 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); |
| 399 | 403 | } else { |
| … |
… |
LayerManager.LayerChangeListener, MainLayerManager.ActiveLayerChangeListener {
|
| 438 | 442 | addEditLayerChangeListener(listener, false); |
| 439 | 443 | } |
| 440 | 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; |
| | 454 | |
| 441 | 455 | public boolean viewportFollowing; |
| 442 | 456 | |
| 443 | 457 | /** |
diff --git a/src/org/openstreetmap/josm/tools/bugreport/BugReport.java b/src/org/openstreetmap/josm/tools/bugreport/BugReport.java
index cfd2fdb..f74af94 100644
|
a
|
b
|
public final class BugReport {
|
| 62 | 62 | * How many methods to look back in the stack trace. 1 gives the method calling this method, 0 gives you getCallingMethod(). |
| 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(); |
| 68 | 68 | for (int i = 0; i < stackTrace.length - offset; i++) { |