aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/render/java2d
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2008-12-07 18:01:24 +0000
committerJeremias Maerki <jeremias@apache.org>2008-12-07 18:01:24 +0000
commit790875d4101f90ab3419025717b581c255d87fe1 (patch)
treeeff1d1eb3a61dfe96b5779823c49d40d79020455 /src/java/org/apache/fop/render/java2d
parent61cd1e8790969b9d3c96fcfb6231fd77c1a2b33b (diff)
downloadxmlgraphics-fop-790875d4101f90ab3419025717b581c255d87fe1.tar.gz
xmlgraphics-fop-790875d4101f90ab3419025717b581c255d87fe1.zip
Bugzilla #46360:
Fixed a multi-threading issue when rendering SVG. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@724163 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/render/java2d')
-rw-r--r--src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java b/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java
index ba5c86059..2d16b120d 100644
--- a/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java
+++ b/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java
@@ -23,18 +23,21 @@ import java.awt.geom.AffineTransform;
import java.io.IOException;
import java.util.Map;
+import org.w3c.dom.Document;
+
import org.apache.batik.bridge.BridgeContext;
import org.apache.batik.bridge.GVTBuilder;
+import org.apache.batik.dom.util.DOMUtilities;
import org.apache.batik.gvt.GraphicsNode;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.apache.fop.render.AbstractGenericSVGHandler;
import org.apache.fop.render.Renderer;
import org.apache.fop.render.RendererContext;
import org.apache.fop.render.RendererContextConstants;
import org.apache.fop.svg.SVGEventProducer;
import org.apache.fop.svg.SVGUserAgent;
-import org.w3c.dom.Document;
/**
* Java2D XML handler for SVG (uses Apache Batik).
@@ -128,12 +131,16 @@ public class Java2DSVGHandler extends AbstractGenericSVGHandler
SVGUserAgent ua = new SVGUserAgent(context.getUserAgent(), new AffineTransform());
- GVTBuilder builder = new GVTBuilder();
BridgeContext ctx = new BridgeContext(ua);
+ //Cloning SVG DOM as Batik attaches non-thread-safe facilities (like the CSS engine)
+ //to it.
+ Document clonedDoc = DOMUtilities.deepCloneDocument(doc, doc.getImplementation());
+
GraphicsNode root;
try {
- root = builder.build(ctx, doc);
+ GVTBuilder builder = new GVTBuilder();
+ root = builder.build(ctx, clonedDoc);
} catch (Exception e) {
SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
context.getUserAgent().getEventBroadcaster());