Ticket #23415: 23415.patch

File 23415.patch, 2.9 KB (added by GerdP, 5 months ago)
  • src/org/openstreetmap/josm/gui/layer/geoimage/ImageViewerDialog.java

     
    146146    private static void destroyInstance() {
    147147        MapFrame map = MainApplication.getMap();
    148148        synchronized (ImageViewerDialog.class) {
    149             if (dialog != null && map != null && map.getToggleDialog(ImageViewerDialog.class) != null) {
    150                 map.removeToggleDialog(dialog);
     149            if (dialog != null) {
     150                if (map != null && map.getToggleDialog(ImageViewerDialog.class) != null) {
     151                    map.removeToggleDialog(dialog);
     152                }
     153                dialog.destroy();
    151154            }
    152155        }
    153156        dialog = null;
     
    180183        this.layers.getModel().addChangeListener(l -> {
    181184            // We need to check to see whether or not the worker is shut down. See #22922 for details.
    182185            if (!MainApplication.worker.isShutdown() && this.isDialogShowing()) {
    183                 MainApplication.worker.execute(() -> GuiHelper.runInEDT(() -> {
    184                     Component selected = this.layers.getSelectedComponent();
    185                     if (selected instanceof MoveImgDisplayPanel) {
    186                         ((MoveImgDisplayPanel<?>) selected).fireModelUpdate();
    187                     }
    188                 }));
     186                MainApplication.worker.execute(() -> GuiHelper.runInEDT(this::showNotify));
    189187            }
    190188        });
    191189    }
     
    302300                .filter(IGeoImageLayer.class::isInstance).map(IGeoImageLayer.class::cast).collect(Collectors.toList());
    303301        if (geoImageLayers.isEmpty()) {
    304302            this.layers.setVisible(false);
     303            hideNotify();
     304            if (hasInstance())
     305                destroyInstance();
    305306        } else {
    306307            this.layers.setVisible(true);
    307308            if (changed) {
     
    351352                        if (index >= 0) {
    352353                            removeImageTab(((MoveImgDisplayPanel<?>) layers.getComponentAt(index)).layer);
    353354                            getImageTabs().forEach(m -> m.setVisible(m.isVisible()));
     355                            showNotify();
    354356                            return;
    355357                        }
    356358                        source = source.getParent();
     
    416418        imageRemoveAction.destroy();
    417419        imageRemoveFromDiskAction.destroy();
    418420        imageZoomAction.destroy();
     421        toggleAction.destroy();
    419422        cancelLoadingImage();
    420423        super.destroy();
    421         destroyInstance();
    422424    }
    423425
    424426    /**
     
    10651067        if (btnCollapse != null) {
    10661068            btnCollapse.setVisible(!isDocked);
    10671069        }
    1068         this.updateLayers(true);
    10691070    }
    10701071
    10711072    /**