Changeset 7805 in josm


Ignore:
Timestamp:
2014-12-15T20:44:26+01:00 (9 years ago)
Author:
bastiK
Message:

see #10836 - svg salamander not thread safe when parsing the svg xml

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/ImageProvider.java

    r7804 r7805  
    667667            switch (type) {
    668668            case SVG:
    669                 URI uri = getSvgUniverse().loadSVG(is, Utils.fileToURL(cf.getFile()).toString());
    670                 SVGDiagram svg = getSvgUniverse().getDiagram(uri);
     669                SVGDiagram svg = null;
     670                synchronized (getSvgUniverse()) {
     671                    URI uri = getSvgUniverse().loadSVG(is, Utils.fileToURL(cf.getFile()).toString());
     672                    svg = getSvgUniverse().getDiagram(uri);
     673                }
    671674                return svg == null ? null : new ImageResource(svg);
    672675            case OTHER:
     
    706709                if ("image/svg+xml".equals(mediatype)) {
    707710                    String s = new String(bytes, StandardCharsets.UTF_8);
    708                     URI uri = getSvgUniverse().loadSVG(new StringReader(s), URLEncoder.encode(s, "UTF-8"));
    709                     SVGDiagram svg = getSvgUniverse().getDiagram(uri);
     711                    SVGDiagram svg = null;
     712                    synchronized (getSvgUniverse()) {
     713                        URI uri = getSvgUniverse().loadSVG(new StringReader(s), URLEncoder.encode(s, "UTF-8"));
     714                        svg = getSvgUniverse().getDiagram(uri);
     715                    }
    710716                    if (svg == null) {
    711717                        Main.warn("Unable to process svg: "+s);
     
    777783                    switch (type) {
    778784                    case SVG:
    779                         URI uri = getSvgUniverse().loadSVG(is, entryName);
    780                         SVGDiagram svg = getSvgUniverse().getDiagram(uri);
     785                        SVGDiagram svg = null;
     786                        synchronized (getSvgUniverse()) {
     787                            URI uri = getSvgUniverse().loadSVG(is, entryName);
     788                            svg = getSvgUniverse().getDiagram(uri);
     789                        }
    781790                        return svg == null ? null : new ImageResource(svg);
    782791                    case OTHER:
     
    808817        switch (type) {
    809818        case SVG:
    810             URI uri = getSvgUniverse().loadSVG(path);
    811             SVGDiagram svg = getSvgUniverse().getDiagram(uri);
     819            SVGDiagram svg = null;
     820            synchronized (getSvgUniverse()) {
     821                URI uri = getSvgUniverse().loadSVG(path);
     822                svg = getSvgUniverse().getDiagram(uri);
     823            }
    812824            return svg == null ? null : new ImageResource(svg);
    813825        case OTHER:
Note: See TracChangeset for help on using the changeset viewer.