Changeset 13250 in josm for trunk/src/org


Ignore:
Timestamp:
2017-12-28T00:53:58+01:00 (7 years ago)
Author:
Don-vip
Message:

fix #15654 - repair asynchronous fetching of icons (regression from r10714) + fetch https icons asynchronously (omission from r10731)

Location:
trunk/src/org/openstreetmap/josm
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java

    r13206 r13250  
    7676        String icon = info.getIcon();
    7777        if (icon != null) {
    78             new ImageProvider(icon).setOptional(true).getResourceAsync().thenAccept(result -> {
     78            new ImageProvider(icon).setOptional(true).getResourceAsync().thenAcceptAsync(result -> {
    7979                if (result != null) {
    8080                    GuiHelper.runInEDT(() -> result.attachImageIcon(this));
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/MapImage.java

    r12722 r13250  
    139139                .setHeight(height)
    140140                .setOptional(true)
    141                 .getAsync().thenAccept(result -> {
     141                .getAsync().thenAcceptAsync(result -> {
    142142                    synchronized (this) {
    143143                        if (result == null) {
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java

    r13130 r13250  
    217217        imgProv.setArchive(arch);
    218218        imgProv.setOptional(true);
    219         imgProv.getResourceAsync().thenAccept(result -> {
     219        imgProv.getResourceAsync().thenAcceptAsync(result -> {
    220220            if (result != null) {
    221221                GuiHelper.runInEDT(() -> result.attachImageIcon(this));
  • trunk/src/org/openstreetmap/josm/tools/ImageProvider.java

    r13186 r13250  
    631631
    632632    /**
     633     * Determines if this icon is located on a remote location (http, https, wiki).
     634     * @return {@code true} if this icon is located on a remote location (http, https, wiki)
     635     * @since 13250
     636     */
     637    public boolean isRemote() {
     638        return name.startsWith(HTTP_PROTOCOL) || name.startsWith(HTTPS_PROTOCOL) || name.startsWith(WIKI_PROTOCOL);
     639    }
     640
     641    /**
    633642     * Execute the image request and scale result.
    634643     * @return the requested image or null if the request failed
     
    655664     */
    656665    public CompletableFuture<ImageIcon> getAsync() {
    657         return name.startsWith(HTTP_PROTOCOL) || name.startsWith(WIKI_PROTOCOL)
     666        return isRemote()
    658667                ? CompletableFuture.supplyAsync(this::get, IMAGE_FETCHER)
    659668                : CompletableFuture.completedFuture(get());
     
    699708     */
    700709    public CompletableFuture<ImageResource> getResourceAsync() {
    701         return name.startsWith(HTTP_PROTOCOL) || name.startsWith(WIKI_PROTOCOL)
     710        return isRemote()
    702711                ? CompletableFuture.supplyAsync(this::getResource, IMAGE_FETCHER)
    703712                : CompletableFuture.completedFuture(getResource());
Note: See TracChangeset for help on using the changeset viewer.