- Timestamp:
- 2020-03-16T21:23:20+01:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/MapImage.java
r16062 r16153 10 10 import java.awt.image.BufferedImage; 11 11 import java.util.Objects; 12 import java.util.concurrent.CompletableFuture; 13 import java.util.concurrent.ExecutionException; 12 14 13 15 import javax.swing.ImageIcon; … … 22 24 import org.openstreetmap.josm.tools.ImageProvider; 23 25 import org.openstreetmap.josm.tools.ImageResource; 26 import org.openstreetmap.josm.tools.Logging; 24 27 import org.openstreetmap.josm.tools.Utils; 25 28 … … 115 118 /** 116 119 * Get the image resource associated with this MapImage object. 120 * This method blocks until the image has been loaded. 117 121 * @return the image resource 118 122 */ 119 123 public ImageResource getImageResource() { 124 if (imageResource == null) { 125 try { 126 // load and wait for the image 127 loadImage().get(); 128 } catch (ExecutionException | InterruptedException e) { 129 Logging.warn(e); 130 Thread.currentThread().interrupt(); 131 } 132 } 120 133 return imageResource; 121 134 } … … 142 155 return img; 143 156 temporary = false; 144 new ImageProvider(name) 157 loadImage(); 158 synchronized (this) { 159 if (img == null) { 160 img = ImageProvider.get("clock").getImage(); 161 temporary = true; 162 } 163 } 164 return img; 165 } 166 167 private CompletableFuture<Void> loadImage() { 168 return new ImageProvider(name) 145 169 .setDirs(MapPaintStyles.getIconSourceDirs(source)) 146 170 .setId("mappaint."+source.getPrefName()) … … 168 192 } 169 193 ); 170 synchronized (this) {171 if (img == null) {172 img = ImageProvider.get("clock").getImage();173 temporary = true;174 }175 }176 return img;177 194 } 178 195
Note:
See TracChangeset
for help on using the changeset viewer.