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/device.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'source/fitz/device.c') diff --git a/source/fitz/device.c b/source/fitz/device.c index 4379bb21..88b658a3 100644 --- a/source/fitz/device.c +++ b/source/fitz/device.c @@ -13,11 +13,11 @@ fz_close_device(fz_context *ctx, fz_device *dev) { if (dev == NULL) return; - if (dev->close) - dev->close(ctx, dev); + if (dev->close_device) + dev->close_device(ctx, dev); /* Don't call more than once! */ - dev->close = NULL; + dev->close_device = NULL; /* And disable all further device calls. */ dev->fill_path = NULL; @@ -53,8 +53,10 @@ fz_drop_device(fz_context *ctx, fz_device *dev) { if (fz_drop_imp(ctx, dev, &dev->refs)) { - if (dev->close) - dev->close(ctx, dev); + if (dev->close_device) + fz_warn(ctx, "dropping unclosed device"); + if (dev->drop_device) + dev->drop_device(ctx, dev); fz_free(ctx, dev->container); fz_free(ctx, dev); } -- cgit v1.2.3