diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2016-07-08 12:04:35 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2016-07-08 17:21:24 +0200 |
commit | 10d6eaa73164b58c91ae8a4537b8a8589038a01d (patch) | |
tree | 5b739b0c2202b42a9079ee3ecbd98c3d3b09b124 /source/fitz/device.c | |
parent | b53e7a42f7cc9756ed9fa1fed313271e3ae67855 (diff) | |
download | mupdf-10d6eaa73164b58c91ae8a4537b8a8589038a01d.tar.xz |
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).
Diffstat (limited to 'source/fitz/device.c')
-rw-r--r-- | source/fitz/device.c | 12 |
1 files changed, 7 insertions, 5 deletions
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); } |