Ticket #12897: patch-layer-list-lifecycle-quickfix.patch

File patch-layer-list-lifecycle-quickfix.patch, 1.6 KB (added by michael2402, 3 years ago)
  • src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java

    diff --git a/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java b/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
    index d1917bd..617dc36 100644
    a b public class LayerListDialog extends ToggleDialog { 
    122122    private final ActivateLayerAction activateLayerAction;
    123123    private final ShowHideLayerAction showHideLayerAction;
    124124
     125    /**
     126     * Set if {@link #showNotify()} was called. To be removed when lifecycle is fixed.
     127     */
     128    private boolean isShown;
     129
    125130    //TODO This duplicates ShowHide actions functionality
    126131    /** stores which layer index to toggle and executes the ShowHide action if the layer is present */
    127132    private final class ToggleLayerIndexVisibility extends AbstractAction {
    public class LayerListDialog extends ToggleDialog { 
    329334
    330335    @Override
    331336    public void showNotify() {
     337        if (isShown) {
     338            return;
     339        }
    332340        MapView.addLayerChangeListener(activateLayerAction);
    333341        layerManager.addLayerChangeListener(model);
    334342        layerManager.addActiveLayerChangeListener(model, true);
    335343        model.populate();
     344        isShown = true;
    336345    }
    337346
    338347    @Override
    339348    public void hideNotify() {
     349        if (!isShown) {
     350            return;
     351        }
    340352        layerManager.removeLayerChangeListener(model);
    341353        layerManager.removeActiveLayerChangeListener(model);
    342354        MapView.removeLayerChangeListener(activateLayerAction);
     355        isShown = false;
    343356    }
    344357
    345358    /**