[cairo-commit] cairo/src cairo-output-stream.c, 1.5, 1.6 cairo-pdf-surface.c, 1.36, 1.37

Carl Worth commit at pdx.freedesktop.org
Tue May 17 12:40:58 PDT 2005


Committed by: cworth

Update of /cvs/cairo/cairo/src
In directory gabe:/tmp/cvs-serv1810/src

Modified Files:
	cairo-output-stream.c cairo-pdf-surface.c 
Log Message:

        Two fixes from Kristion Høgsberg:

        * src/cairo-output-stream.c: (_cairo_output_stream_create),
        (_cairo_output_stream_destroy),
        (_cairo_output_stream_create_for_file): Fix to close the file if
        we opened it.

        * src/cairo-pdf-surface.c: (_cairo_pdf_document_finish): Grab the
        status from out of the stream _before_ we destroy the stream.


Index: cairo-output-stream.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-output-stream.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- cairo-output-stream.c	17 May 2005 12:58:02 -0000	1.5
+++ cairo-output-stream.c	17 May 2005 19:40:55 -0000	1.6
@@ -41,8 +41,8 @@
 
 struct _cairo_output_stream {
     cairo_write_func_t		write_data;
-    cairo_destroy_func_t	destroy_closure;
     void			*closure;
+    cairo_bool_t		owns_closure_is_file;
     unsigned long		position;
     cairo_status_t		status;
 };
@@ -59,6 +59,7 @@
 
     stream->write_data = write_data;
     stream->closure = closure;
+    stream->owns_closure_is_file = FALSE;
     stream->position = 0;
     stream->status = CAIRO_STATUS_SUCCESS;
 
@@ -68,6 +69,11 @@
 void
 _cairo_output_stream_destroy (cairo_output_stream_t *stream)
 {
+    if (stream->owns_closure_is_file) {
+	FILE *file = stream->closure;
+	fflush (file);
+	fclose (file);
+    }
     free (stream);
 }
 
@@ -273,6 +279,7 @@
     stream = _cairo_output_stream_create (stdio_write, fp);
     if (stream == NULL)
 	fclose (fp);
+    stream->owns_closure_is_file = TRUE;
 
     return stream;
 }

Index: cairo-pdf-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-pdf-surface.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- cairo-pdf-surface.c	17 May 2005 12:58:02 -0000	1.36
+++ cairo-pdf-surface.c	17 May 2005 19:40:55 -0000	1.37
@@ -2180,6 +2180,7 @@
 static cairo_status_t
 _cairo_pdf_document_finish (cairo_pdf_document_t *document)
 {
+    cairo_status_t status;
     cairo_output_stream_t *output = document->output_stream;
     long offset;
     unsigned int info_id, catalog_id;
@@ -2210,10 +2211,12 @@
 				 "%%%%EOF\r\n",
 				 offset);
 
+    status = _cairo_output_stream_get_status (output);
     _cairo_output_stream_destroy (output);
+
     document->finished = TRUE;
 
-    return _cairo_output_stream_get_status (output);
+    return status;
 }
 
 static cairo_status_t




More information about the cairo-commit mailing list