[cairo] Cairo 1.6.4 Quartz crash: CGImageCreateCopy misuse

Vladimir Vukicevic vladimir at pobox.com
Mon May 5 09:49:55 PDT 2008


On May 4, 2008, at 10:54 PM, Paul Messmer wrote:
>
> If I try to use Cairo 1.6.4 to print from a Cocoa application using  
> the cairo_quartz_surface_create_for_cg_context() and I draw images,  
> I'll crash inside of CoreGraphics decode_image routine when Apple's  
> printing code is doing its thing, long after all the cairo surfaces  
> are flushed and gone.  I believe this is due to the following:
>
> In cairo-quartz-surface.c, line ~749, there is:
>
>   /* Create a copy to ensure that the CGImageRef doesn't depend on  
> the image surface's backing store */
>   *image_out = CGImageCreateCopy (image);
>
> However, I don't believe the Cairo code does what the comment says  
> it does.  I believe that the copy has the same data provider as the  
> original, and still depends on the backing store.  While Apple's  
> documentation doesn't say what kind of copy is done, the CGImage.h  
> header claims:
>
>   /* Return a copy of `image'. Only the image structure itself is  
> copied; the
>    * underlying data is not. */
>   CG_EXTERN CGImageRef CGImageCreateCopy(CGImageRef image);

Ugh.  I fixed a similar bug to this a while ago, but then started  
using CGImageCreateCopy in hopes of avoiding the problem.  I  
mistakenly assumed that 'Copy' was a deep copy, I didn't think to  
check the header.  I'll take a look today, thanks for the report.

     - Vlad



More information about the cairo mailing list