Ticket #2535: missing-icon-npe.patch

File missing-icon-npe.patch, 1.5 KB (added by podolsir, 17 years ago)

proposed solution: ignore the icon style spec if icon would be null

  • src/org/openstreetmap/josm/gui/mappaint/ElemStyleHandler.java

    a b  
    22
    33import java.awt.Color;
    44
     5import javax.swing.ImageIcon;
     6
    57import org.openstreetmap.josm.tools.ColorHelper;
    68import org.xml.sax.Attributes;
    79import org.xml.sax.helpers.DefaultHandler;
     
    169171            }
    170172            else if (qName.equals("icon"))
    171173            {
    172                 hadIcon = inIcon = true;
     174                inIcon = true;
    173175                for (int count=0; count<atts.getLength(); count++)
    174176                {
    175                     if (atts.getQName(count).equals("src"))
    176                         rule.icon.icon = MapPaintStyles.getIcon(atts.getValue(count), styleName);
    177                     else if (atts.getQName(count).equals("annotate"))
     177                    if (atts.getQName(count).equals("src")) {
     178                        ImageIcon icon = MapPaintStyles.getIcon(atts.getValue(count), styleName);
     179                        hadIcon = (icon != null);
     180                        rule.icon.icon = icon;
     181                    } else if (atts.getQName(count).equals("annotate"))
    178182                        rule.icon.annotate = Boolean.parseBoolean (atts.getValue(count));
    179183                    else if(atts.getQName(count).equals("priority"))
    180184                        rule.icon.priority = Integer.parseInt(atts.getValue(count));