[cp-patches] RFC: deadlock with Componet/CairoGraphics.drawImage()

Mark Wielaard mark at klomp.org
Sat Jun 10 21:17:06 UTC 2006


Hi,

I was seeing deadlocks in some cases with ComponentGraphics.drawImage().
ComponentGraphics takes the gdk lock and then calls super.drawImage().
But in some cases when the image isn't a BufferedImage CairoGraphics
would recurse into drawImage() again. And since the gdk lock isn't
reentrant that would cause a deadlock. There was a second problem if the
image was the error image, in that case it wouldn't have a ImageProducer
and later on in CairoGraphics.drawImage() an Exception would be thrown.
In that case the gdk lock would never be released. To prevent against
such situations this patch also moves all operations that have to
operate with the gdk lock held into a try-finally block to make sure the
lock is always released.

2006-06-10  Mark Wielaard  <mark at klomp.org>

    * gnu/java/awt/peer/gtk/CairoGraphics2D.java (drawImage):
    Don't recurse, return false if not an BufferedImage and no image
    source available.
    * gnu/java/awt/peer/gtk/ComponentGraphics.java (draw): Add
    end_gdk_drawing() to finally block.
    (fill): Likewise.
    (drawRenderedImage): Likewise.
    (drawImage): Likewise.
    (drawGlyphVector): Likewise.

Does this look sane?

Thanks,

Mark
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gdk-deadlock.patch
Type: text/x-patch
Size: 3217 bytes
Desc: not available
Url : http://developer.classpath.org/pipermail/classpath-patches/attachments/20060610/df34465c/gdk-deadlock.bin


More information about the Classpath-patches mailing list