Changeset 18686 in josm
- Timestamp:
- 2023-03-08T20:00:36+01:00 (21 months ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/DialogsPanel.java
r17374 r18686 105 105 } else { 106 106 dlg.hideDialog(); 107 } 108 } 109 110 /** 111 * Remove a {@link ToggleDialog} from the list of known dialogs and trigger reconstruct. 112 * @param toggleDialog The dialog to remove 113 * @since 18686 114 */ 115 public void remove(ToggleDialog toggleDialog) { 116 remove(toggleDialog, true); 117 } 118 119 /** 120 * Remove a {@link ToggleDialog} from the list of known dialogs. 121 * @param toggleDialog The dialog to remove 122 * @param doReconstruct <code>true</code> if reconstruction should be triggered. 123 * @since 18686 124 */ 125 public void remove(ToggleDialog toggleDialog, boolean doReconstruct) { 126 toggleDialog.setDialogsPanel(null); 127 final JPanel oldPanel = panels.get(allDialogs.indexOf(toggleDialog)); 128 allDialogs.remove(toggleDialog); 129 panels.remove(oldPanel); 130 mSpltPane.remove(oldPanel); 131 if (doReconstruct && !allDialogs.isEmpty()) { 132 reconstruct(Action.ELEMENT_SHRINKS, toggleDialog); 107 133 } 108 134 } … … 326 352 @Override 327 353 public void destroy() { 328 for (ToggleDialog t : allDialogs) {354 for (ToggleDialog t : new ArrayList<>(allDialogs)) { 329 355 try { 330 356 t.destroy(); -
trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
r18216 r18686 478 478 @Override 479 479 public void destroy() { 480 dialogsPanel = null; 480 if (dialogsPanel != null) { 481 dialogsPanel.remove(this); 482 dialogsPanel = null; 483 } 481 484 rememberHeight(); 482 485 closeDetachedDialog(); -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageViewerDialog.java
r18685 r18686 145 145 */ 146 146 private static void destroyInstance() { 147 MapFrame map = MainApplication.getMap(); 148 synchronized (ImageViewerDialog.class) { 149 if (dialog != null && map != null && map.getToggleDialog(ImageViewerDialog.class) != null) { 150 map.removeToggleDialog(dialog); 151 } 152 } 147 153 dialog = null; 148 154 } -
trunk/test/unit/org/openstreetmap/josm/gui/layer/geoimage/ImageViewerDialogTest.java
r18685 r18686 21 21 import javax.swing.JPanel; 22 22 23 import org.junit.jupiter.api.AfterEach; 23 24 import org.junit.jupiter.api.BeforeEach; 24 25 import org.junit.jupiter.api.extension.RegisterExtension; … … 44 45 45 46 private ImageViewerDialog dialog; 47 46 48 @BeforeEach 47 49 void setup() { 48 50 this.dialog = ImageViewerDialog.getInstance(); 49 51 this.dialog.displayImages(null); 52 } 53 54 @AfterEach 55 void tearDown() { 56 this.dialog.destroy(); 50 57 } 51 58 -
trunk/test/unit/org/openstreetmap/josm/gui/layer/geoimage/ImagesLoaderTest.java
r18035 r18686 10 10 import java.util.List; 11 11 12 import org.junit.jupiter.api.AfterEach; 12 13 import org.junit.jupiter.api.Test; 13 import org.junit.jupiter.api.extension.RegisterExtension;14 14 import org.openstreetmap.josm.TestUtils; 15 15 import org.openstreetmap.josm.gui.MainApplication; 16 16 import org.openstreetmap.josm.gui.layer.GpxLayer; 17 17 import org.openstreetmap.josm.io.GpxReader; 18 import org.openstreetmap.josm.testutils.JOSMTestRules; 19 20 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 18 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 21 19 22 20 /** 23 21 * Unit tests of {@link ImagesLoader} class. 24 22 */ 23 @BasicPreferences 25 24 class ImagesLoaderTest { 26 25 27 /**28 * We need prefs for this.29 */30 @RegisterExtension31 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")32 public JOSMTestRules test = new JOSMTestRules().preferences();26 @AfterEach 27 void tearDown() { 28 if (ImageViewerDialog.hasInstance()) { 29 ImageViewerDialog.getInstance().destroy(); 30 } 31 } 33 32 34 33 /** -
trunk/test/unit/org/openstreetmap/josm/gui/layer/geoimage/WikimediaCommonsLoaderTest.java
r18050 r18686 11 11 import java.util.List; 12 12 13 import org.junit.jupiter.api.AfterEach; 13 14 import org.junit.jupiter.api.BeforeAll; 14 15 import org.junit.jupiter.api.Test; … … 29 30 static void beforeAll() { 30 31 HttpClient.setFactory(Http1Client::new); 32 } 33 34 @AfterEach 35 void tearDown() { 36 if (ImageViewerDialog.hasInstance()) { 37 ImageViewerDialog.getInstance().destroy(); 38 } 31 39 } 32 40
Note:
See TracChangeset
for help on using the changeset viewer.