Changeset 19461 in josm for trunk


Ignore:
Timestamp:
2026-01-14T21:32:17+01:00 (41 hours ago)
Author:
stoecker
Message:

should fix Coverity CID 1347996 and CID 1476016

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/MapImage.java

    r18388 r19461  
    3838     * ImageIcon can change while the image is loading.
    3939     */
    40     private Image img;
     40    private volatile Image img;
    4141    private ImageResource imageResource;
    4242
     
    8080     * A cache that holds a disabled (gray) version of this image
    8181     */
    82     private BufferedImage disabledImgCache;
     82    private volatile BufferedImage disabledImgCache;
    8383
    8484    /**
     
    142142        // This should fix #21919: NPE due to disabledImgCache being null (race condition with #loadImage())
    143143        synchronized (this) {
    144             Image disImg = GuiHelper.getDisabledImage(img);
    145             if (disImg instanceof BufferedImage) {
    146                 disabledImgCache = (BufferedImage) disImg;
    147             } else {
    148                 disabledImgCache = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB);
    149                 Graphics g = disabledImgCache.getGraphics();
    150                 g.drawImage(disImg, 0, 0, null);
    151                 g.dispose();
     144            if(disabledImgCache != null) {
     145                Image disImg = GuiHelper.getDisabledImage(img);
     146                if (disImg instanceof BufferedImage) {
     147                    disabledImgCache = (BufferedImage) disImg;
     148                } else {
     149                    disabledImgCache = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB);
     150                    Graphics g = disabledImgCache.getGraphics();
     151                    g.drawImage(disImg, 0, 0, null);
     152                    g.dispose();
     153                }
    152154            }
    153155        }
Note: See TracChangeset for help on using the changeset viewer.