[
https://issues.apache.org/jira/browse/BATIK-1290?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Emmeran Seehuber updated BATIK-1290:
------------------------------------
Attachment: batik_gvt_fix_danlging_gfx.patch
> AbstractGraphicsNode.paint() somethings does not dispose a Graphics2D child
> context
> -----------------------------------------------------------------------------------
>
> Key: BATIK-1290
> URL: https://issues.apache.org/jira/browse/BATIK-1290
> Project: Batik
> Issue Type: Bug
> Components: GVT
> Affects Versions: 1.13, 1.12
> Reporter: Emmeran Seehuber
> Priority: Major
> Attachments: batik_gvt_fix_danlging_gfx.patch, openhtml_536.svg
>
>
> In some (rare?) cases, org.apache.batik.gvt.AbstractGraphicsNode::paint()
> calls g2d.create() twice, but only calls dispose() on one of the child
> Graphics2D.
> Because a clip is set, in line 456 the first child Graphics2D is created.
> Later in line 503 useOffscreen is true. This causes in line 535 the baseG2d
> (which was stored to be later be dispose()ed) is overridden the the child
> created in line 456. Then in line 539 a new child Graphics2D is created. And
> only this second child is disposed in line 552, the first child is never
> disposed.
> This is a problem if the used Graphics2D needs the dispose() calls to be
> "balanced" and correct. Which is the case when using it with my
> PdfBoxGraphics2D-Adapter ([https://github.com/rototor/pdfbox-graphics2d]).
> The child Graphics2D write a "q" (Save State) into the PDF stream and
> therefore need a matching "Q" (Restore State) - which is written when calling
> dispose(). Otherwise the PDF would be invalid.
> The attached patch fixes this by only creating a child Graphics2D if not
> already one exists.
> I also attached the SVG file that triggers the problem. It has transparency,
> so it is rendered to an offscreen image first but also has a clip set.
> For a "ready to use" example to reproduce this bug you can clone
> [https://github.com/rototor/pdfbox-graphics2d], enable the testcase for this
> ([https://github.com/rototor/pdfbox-graphics2d/blob/master/src/test/java/de/rototor/pdfbox/graphics2d/RenderSVGsTest.java#L40])
> and run mvn test. It will then fail because of this bug.
> This issue was originally reported in the openhtmltopdf project
> ([https://github.com/danfickle/openhtmltopdf/issues/536])
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-h...@xmlgraphics.apache.org