]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Bugzilla #46360:
authorJeremias Maerki <jeremias@apache.org>
Thu, 16 Sep 2010 06:29:08 +0000 (06:29 +0000)
committerJeremias Maerki <jeremias@apache.org>
Thu, 16 Sep 2010 06:29:08 +0000 (06:29 +0000)
Fixed a multi-threading issue when rendering SVG.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@997602 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/render/ps/PSImageHandlerSVG.java

index 41cba7563e67cd2012cb8220a9b8f92d4b9322e5..839a0cab6c95feadbb87756301466b4e02986fed 100644 (file)
@@ -23,6 +23,8 @@ import java.awt.Rectangle;
 import java.awt.geom.AffineTransform;
 import java.io.IOException;
 
+import org.w3c.dom.Document;
+
 import org.apache.batik.bridge.BridgeContext;
 import org.apache.batik.bridge.GVTBuilder;
 import org.apache.batik.gvt.GraphicsNode;
@@ -34,6 +36,7 @@ import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
 import org.apache.xmlgraphics.ps.PSGenerator;
 
 import org.apache.fop.image.loader.batik.BatikImageFlavors;
+import org.apache.fop.image.loader.batik.BatikUtil;
 import org.apache.fop.render.ImageHandler;
 import org.apache.fop.render.RenderingContext;
 import org.apache.fop.svg.SVGEventProducer;
@@ -70,10 +73,14 @@ public class PSImageHandlerSVG implements ImageHandler {
                 context.getUserAgent().getFactory().getImageManager(),
                 context.getUserAgent().getImageSessionContext());
 
+        //Cloning SVG DOM as Batik attaches non-thread-safe facilities (like the CSS engine)
+        //to it.
+        Document clonedDoc = BatikUtil.cloneSVGDocument(imageSVG.getDocument());
+
         GraphicsNode root;
         try {
             GVTBuilder builder = new GVTBuilder();
-            root = builder.build(ctx, imageSVG.getDocument());
+            root = builder.build(ctx, clonedDoc);
         } catch (Exception e) {
             SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
                     context.getUserAgent().getEventBroadcaster());