From 10d6eaa73164b58c91ae8a4537b8a8589038a01d Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 8 Jul 2016 12:04:35 +0200 Subject: Separate close and drop functionality for devices and writers. Closing a device or writer may throw exceptions, but much of the foreign language bindings (JNI and JS) depend on drop to never throw an exception (exceptions in finalizers are bad). --- source/fitz/writer.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'source/fitz/writer.c') diff --git a/source/fitz/writer.c b/source/fitz/writer.c index 556e01a8..c4e95e2a 100644 --- a/source/fitz/writer.c +++ b/source/fitz/writer.c @@ -67,16 +67,18 @@ fz_new_document_writer(fz_context *ctx, const char *path, const char *format, co void fz_close_document_writer(fz_context *ctx, fz_document_writer *wri) { - if (wri->close) - wri->close(ctx, wri); - wri->close = NULL; + if (wri->close_writer) + wri->close_writer(ctx, wri); + wri->close_writer = NULL; } void fz_drop_document_writer(fz_context *ctx, fz_document_writer *wri) { - if (wri->close) - wri->close(ctx, wri); + if (wri->close_writer) + fz_warn(ctx, "dropping unclosed document writer"); + if (wri->drop_writer) + wri->drop_writer(ctx, wri); fz_free(ctx, wri); } -- cgit v1.2.3