Skip to content

Commit

Permalink
fix #23415 and #23414, patch 23415-v2.patch
Browse files Browse the repository at this point in the history
- fixes issues where the wrong image is shown 
- properly destroys the toggle dialog and the toggle action when no more geotagged image layer is available
- make sure that the title is updated when no image is selected (instead of possibly showing an image name from a closed layer


git-svn-id: https://josm.openstreetmap.de/svn/trunk@18937 0c6e7542-c601-0410-84e7-c038aed88b3b
  • Loading branch information
GerdP authored and GerdP committed Jan 15, 2024
1 parent 735b286 commit fb1e7b8
Showing 1 changed file with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,11 @@ public static boolean hasInstance() {
private static void destroyInstance() {
MapFrame map = MainApplication.getMap();
synchronized (ImageViewerDialog.class) {
if (dialog != null && map != null && map.getToggleDialog(ImageViewerDialog.class) != null) {
map.removeToggleDialog(dialog);
if (dialog != null) {
if (map != null && map.getToggleDialog(ImageViewerDialog.class) != null) {
map.removeToggleDialog(dialog);
}
dialog.destroy();
}
}
dialog = null;
Expand Down Expand Up @@ -180,12 +183,7 @@ private ImageViewerDialog() {
this.layers.getModel().addChangeListener(l -> {
// We need to check to see whether or not the worker is shut down. See #22922 for details.
if (!MainApplication.worker.isShutdown() && this.isDialogShowing()) {
MainApplication.worker.execute(() -> GuiHelper.runInEDT(() -> {
Component selected = this.layers.getSelectedComponent();
if (selected instanceof MoveImgDisplayPanel) {
((MoveImgDisplayPanel<?>) selected).fireModelUpdate();
}
}));
MainApplication.worker.execute(() -> GuiHelper.runInEDT(this::showNotify));
}
});
}
Expand Down Expand Up @@ -302,6 +300,9 @@ private void updateLayers(boolean changed) {
.filter(IGeoImageLayer.class::isInstance).map(IGeoImageLayer.class::cast).collect(Collectors.toList());
if (geoImageLayers.isEmpty()) {
this.layers.setVisible(false);
hideNotify();
if (hasInstance())
destroyInstance();
} else {
this.layers.setVisible(true);
if (changed) {
Expand All @@ -314,6 +315,8 @@ private void updateLayers(boolean changed) {
} else if (selected != null && !selected.layer.containsImage(this.currentEntry)) {
this.getImageTabs().filter(m -> m.layer.containsImage(this.currentEntry)).mapToInt(this.layers::indexOfComponent).findFirst()
.ifPresent(this.layers::setSelectedIndex);
} else if (selected == null) {
updateTitle();
}
this.layers.invalidate();
}
Expand Down Expand Up @@ -351,6 +354,7 @@ private void addButtonsForImageLayers() {
if (index >= 0) {
removeImageTab(((MoveImgDisplayPanel<?>) layers.getComponentAt(index)).layer);
getImageTabs().forEach(m -> m.setVisible(m.isVisible()));
showNotify();
return;
}
source = source.getParent();
Expand Down Expand Up @@ -416,9 +420,9 @@ public void destroy() {
imageRemoveAction.destroy();
imageRemoveFromDiskAction.destroy();
imageZoomAction.destroy();
toggleAction.destroy();
cancelLoadingImage();
super.destroy();
destroyInstance();
}

/**
Expand Down Expand Up @@ -1065,7 +1069,6 @@ protected void stateChanged() {
if (btnCollapse != null) {
btnCollapse.setVisible(!isDocked);
}
this.updateLayers(true);
}

/**
Expand Down

0 comments on commit fb1e7b8

Please sign in to comment.