I forgot the mention that the same code compiled against 1.8.6 works without problem on linux.  So I&#39;m pretty sure that there is nothing wrong with the sample code itself.  <br><br>So I&#39;ve tried both:<br><br>cairo_surface_destroy(surface);<br>
cairo_destroy(cr);<div><br>and<br><br>cairo_destroy(cr);<br>cairo_surface_destroy(surface);    <br><div><br>and they both crash.   What next? <br></div> <br>Thanks<br><br>Daz<br></div><br><br><div class="gmail_quote">2009/4/24 Behdad Esfahbod <span dir="ltr">&lt;<a href="mailto:behdad@behdad.org">behdad@behdad.org</a>&gt;</span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">On 04/24/2009 11:59 AM, Gerdus van Zyl wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Try reversing the lines:<br>
     cairo_surface_destroy(surface);<br>
     cairo_destroy(cr);<br>
<br>
destroying the surface before the context looks suspect. and when<br>
working with PDF you might want a cairo_surface_finish before<br>
destroying.<br>
</blockquote>
<br></div>
The context has a reference to the surface.  And _finish should be called automatically *if* the last reference to the surface is dropped.  So, calling it would be a good test to see if that&#39;s the problem.<br><font color="#888888">
<br>
behdad</font><div><div></div><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Fri, Apr 24, 2009 at 4:17 PM, Darren Gallagher&lt;<a href="mailto:dazzag@gmail.com" target="_blank">dazzag@gmail.com</a>&gt;  wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Using 1.8.6 on windows (with pixman 0.15.2).  Built using instructions here:<br>
<a href="http://www.williamcyap.com/software/cairo-lib/compiling-cairo-for-windows.xhtml" target="_blank">http://www.williamcyap.com/software/cairo-lib/compiling-cairo-for-windows.xhtml</a><br>
<br>
produces a crash witin cairo_destroy() somewhere.<br>
<br>
The code is as follows:<br>
<br>
#include&lt;cairo.h&gt;<br>
#include&lt;cairo-pdf.h&gt;<br>
<br>
int main (int argc, char *argv[])<br>
{<br>
     cairo_surface_t *surface;<br>
     cairo_t *cr;<br>
<br>
     surface = cairo_pdf_surface_create (&quot;hellocairo.pdf&quot; , 504, 648);<br>
     cr = cairo_create (surface);<br>
     cairo_set_source_rgb(cr, 0, 0, 0);<br>
     cairo_select_font_face (cr, &quot;serif&quot;, CAIRO_FONT_SLANT_NORMAL,<br>
CAIRO_FONT_WEIGHT_NORMAL);<br>
     cairo_set_font_size (cr, 40.0);<br>
     cairo_move_to(cr, 10.0, 50.0);<br>
     cairo_show_text(cr, &quot;Hello, Cairo!&quot;);<br>
     cairo_show_page(cr);<br>
     cairo_surface_destroy(surface);<br>
     cairo_destroy(cr);<br>
<br>
     return 0;<br>
}<br>
<br>
the stack is as follows:<br>
<br>
      ntdll.dll!7c90120e()<br>
      [Frames below may be incorrect and/or missing, no symbols loaded for<br>
ntdll.dll]<br>
      ntdll.dll!7c96c201()<br>
      ntdll.dll!7c96c63e()<br>
      ntdll.dll!7c9603b0()<br>
      kernel32.dll!7c85f8d7()<br>
      msvcr80d.dll!_CrtIsValidHeapPointer(const void * pUserData=0x00955c50)<br>
Line 2072    C++<br>
      msvcr80d.dll!_free_dbg_nolock(void * pUserData=0x00955c50, int<br>
nBlockUse=1)  Line 1279 + 0x9 bytes    C++<br>
      msvcr80d.dll!_free_dbg(void * pUserData=0x00955c50, int nBlockUse=1)<br>
Line 1220 + 0xd bytes    C++<br>
      msvcr80d.dll!free(void * pUserData=0x00955c50)  Line 1178 + 0xb<br>
bytes    C++<br>
      libcairod.dll!_cairo_truetype_subset_fini(_cairo_truetype_subset *<br>
subset=0x0012f22c)  Line 1171 + 0xe bytes    C<br>
<br>
libcairod.dll!_cairo_pdf_surface_emit_truetype_font_subset(_cairo_pdf_surface<br>
* surface=0x00436fe0, _cairo_scaled_font_subset * font_subset=0x0012f4c8)<br>
Line 3451 + 0xc bytes    C<br>
<br>
libcairod.dll!_cairo_pdf_surface_emit_unscaled_font_subset(_cairo_scaled_font_subset<br>
* font_subset=0x0012f4c8, void * closure=0x00436fe0)  Line 3722 + 0xd<br>
bytes    C<br>
      libcairod.dll!_cairo_sub_font_collect(void * entry=0x0043af78, void *<br>
closure=0x0012f614)  Line 578 + 0x15 bytes    C<br>
<br>
libcairod.dll!_cairo_scaled_font_subsets_foreach_internal(_cairo_scaled_font_subsets<br>
* font_subsets=0x004386b8, _cairo_status (_cairo_scaled_font_subset *, void<br>
*)* font_subset_callback=0x100b67a0, void * closure=0x00436fe0,<br>
cairo_subsets_foreach_type_t type=CAIRO_SUBSETS_FOREACH_UNSCALED)  Line 889<br>
+ 0xd bytes    C<br>
<br>
libcairod.dll!_cairo_scaled_font_subsets_foreach_unscaled(_cairo_scaled_font_subsets<br>
* font_subsets=0x004386b8, _cairo_status (_cairo_scaled_font_subset *, void<br>
*)* font_subset_callback=0x100b67a0, void * closure=0x00436fe0)  Line 918 +<br>
0x13 bytes    C<br>
      libcairod.dll!_cairo_pdf_surface_emit_font_subsets(_cairo_pdf_surface *<br>
surface=0x00436fe0)  Line 3774 + 0x18 bytes    C<br>
      libcairod.dll!_cairo_pdf_surface_finish(void *<br>
abstract_surface=0x00436fe0)  Line 1195 + 0x9 bytes    C<br>
      libcairod.dll!cairo_surface_finish(_cairo_surface *<br>
surface=0x00436fe0)  Line 530 + 0x10 bytes    C<br>
      libcairod.dll!_cairo_paginated_surface_finish(void *<br>
abstract_surface=0x00433998)  Line 172 + 0xf bytes    C<br>
      libcairod.dll!cairo_surface_finish(_cairo_surface *<br>
surface=0x00433998)  Line 530 + 0x10 bytes    C<br>
      libcairod.dll!cairo_surface_destroy(_cairo_surface *<br>
surface=0x00433998)  Line 435 + 0x9 bytes    C<br>
      libcairod.dll!_cairo_gstate_fini(_cairo_gstate * gstate=0x00438a30)<br>
Line 205 + 0xf bytes    C<br>
      libcairod.dll!cairo_destroy(_cairo * cr=0x00438a10)  Line 228 + 0xc<br>
bytes    C<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
     hellocairo.exe!main(int argc=2, char * * argv=0x00436f58)  Line 49 +<br>
0xc bytes    C<br>
</blockquote>
      hellocairo.exe!__tmainCRTStartup()  Line 597 + 0x19 bytes    C<br>
      hellocairo.exe!mainCRTStartup()  Line 414    C<br>
      kernel32.dll!7c817067()<br>
<br>
Any help appreciated.<br>
<br>
Thanks<br>
<br>
Daz<br>
<br>
<br>
_______________________________________________<br>
cairo mailing list<br>
<a href="mailto:cairo@cairographics.org" target="_blank">cairo@cairographics.org</a><br>
<a href="http://lists.cairographics.org/mailman/listinfo/cairo" target="_blank">http://lists.cairographics.org/mailman/listinfo/cairo</a><br>
<br>
</blockquote>
_______________________________________________<br>
cairo mailing list<br>
<a href="mailto:cairo@cairographics.org" target="_blank">cairo@cairographics.org</a><br>
<a href="http://lists.cairographics.org/mailman/listinfo/cairo" target="_blank">http://lists.cairographics.org/mailman/listinfo/cairo</a><br>
<br>
</blockquote>
</div></div></blockquote></div><br>