File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed
src/org/openstreetmap/josm Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -284,9 +284,14 @@ public void setIcon(final String iconName) {
284284 .setOptional (true )
285285 .getResourceAsync (result -> {
286286 if (result != null ) {
287+ // Pre-render off EDT to avoid flooding the event queue with expensive SVG rendering
288+ ImageIcon small = result .getImageIcon (ImageProvider .ImageSizes .SMALLICON .getImageDimension ());
289+ ImageIcon large = result .getImageIcon (ImageProvider .ImageSizes .LARGEICON .getImageDimension ());
287290 GuiHelper .runInEDT (() -> {
288291 try {
289- result .attachImageIcon (this , true );
292+ putValue (Action .SMALL_ICON , small );
293+ putValue (Action .LARGE_ICON_KEY , large );
294+ putValue ("ImageResource" , result );
290295 } catch (IllegalArgumentException e ) {
291296 Logging .warn (toString () + ": " + PRESET_ICON_ERROR_MSG_PREFIX + iconName );
292297 Logging .warn (e );
Original file line number Diff line number Diff line change @@ -724,9 +724,7 @@ public ImageResource getResource() {
724724 * @since 13252
725725 */
726726 public CompletableFuture <Void > getResourceAsync (Consumer <? super ImageResource > action ) {
727- return isRemote ()
728- ? CompletableFuture .supplyAsync (this ::getResource , IMAGE_FETCHER ).thenAcceptAsync (action , IMAGE_FETCHER )
729- : CompletableFuture .completedFuture (getResource ()).thenAccept (action );
727+ return CompletableFuture .supplyAsync (this ::getResource , IMAGE_FETCHER ).thenAcceptAsync (action , IMAGE_FETCHER );
730728 }
731729
732730 /**
You can’t perform that action at this time.
0 commit comments