mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-04 22:18:29 +02:00
Two fixes from Kristion Høgsberg:
Fix to close the file if we opened it. Grab the status from out of the stream _before_ we destroy the stream.
This commit is contained in:
parent
b4710711b8
commit
f0923288c5
3 changed files with 24 additions and 2 deletions
12
ChangeLog
12
ChangeLog
|
|
@ -1,3 +1,15 @@
|
|||
2005-05-17 Carl Worth <cworth@cworth.org>
|
||||
|
||||
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.
|
||||
|
||||
2005-05-17 Keith Packard <keithp@keithp.com>
|
||||
|
||||
* src/cairo-xlib-surface.c: (_get_image_surface):
|
||||
|
|
|
|||
|
|
@ -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 @@ _cairo_output_stream_create (cairo_write_func_t write_data,
|
|||
|
||||
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 @@ _cairo_output_stream_create (cairo_write_func_t write_data,
|
|||
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 @@ _cairo_output_stream_create_for_file (const char *filename)
|
|||
stream = _cairo_output_stream_create (stdio_write, fp);
|
||||
if (stream == NULL)
|
||||
fclose (fp);
|
||||
stream->owns_closure_is_file = TRUE;
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2180,6 +2180,7 @@ _cairo_pdf_document_destroy (cairo_pdf_document_t *document)
|
|||
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 @@ _cairo_pdf_document_finish (cairo_pdf_document_t *document)
|
|||
"%%%%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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue