Changeset 17770 in josm


Ignore:
Timestamp:
2021-04-13T21:12:10+02:00 (4 years ago)
Author:
simon04
Message:

see #20744, fix #20757 - MapCSS: fix NPE

Regression of r17758.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Instruction.java

    r15983 r17770  
    1010import org.openstreetmap.josm.gui.mappaint.MapPaintStyles.IconReference;
    1111import org.openstreetmap.josm.gui.mappaint.StyleKeys;
     12import org.openstreetmap.josm.tools.Logging;
    1213
    1314/**
     
    9192            Object value;
    9293            if (val instanceof Expression) {
    93                 value = ((Expression) val).evaluate(env);
     94                try {
     95                    value = ((Expression) val).evaluate(env);
     96                } catch (RuntimeException ex) {
     97                    Logging.error(ex);
     98                    value = null;
     99                }
    94100            } else {
    95101                value = val;
  • trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.java

    r17769 r17770  
    721721        assertEquals("Error at line 1, column 17: Invalid pseudo class specified: foobar", sheet.getErrors().iterator().next().getMessage());
    722722    }
     723
     724    /**
     725     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/20757">Bug #20757</a>.
     726     */
     727    @Test
     728    void testTicket20757() {
     729        MapCSSStyleSource source = new MapCSSStyleSource("node {name: osm_user_name()}");
     730        source.loadStyleSource();
     731        MultiCascade mc = new MultiCascade();
     732        source.apply(mc, OsmUtils.createPrimitive("node"), 20, false);
     733        assertNull(mc.getCascade(null).get("name"));
     734    }
    723735}
Note: See TracChangeset for help on using the changeset viewer.