summaryrefslogtreecommitdiff
path: root/source/tools/murun.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2016-07-08 12:04:35 +0200
committerTor Andersson <tor.andersson@artifex.com>2016-07-08 17:21:24 +0200
commit10d6eaa73164b58c91ae8a4537b8a8589038a01d (patch)
tree5b739b0c2202b42a9079ee3ecbd98c3d3b09b124 /source/tools/murun.c
parentb53e7a42f7cc9756ed9fa1fed313271e3ae67855 (diff)
downloadmupdf-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/tools/murun.c')
-rw-r--r--source/tools/murun.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/source/tools/murun.c b/source/tools/murun.c
index a3eacaa8..fb35f0a0 100644
--- a/source/tools/murun.c
+++ b/source/tools/murun.c
@@ -178,7 +178,10 @@ static const char *require_js =
static void ffi_gc_fz_buffer(js_State *J, void *buf)
{
fz_context *ctx = js_getcontext(J);
- fz_drop_buffer(ctx, buf);
+ fz_try(ctx)
+ fz_drop_buffer(ctx, buf);
+ fz_catch(ctx)
+ rethrow(J);
}
static void ffi_gc_fz_document(js_State *J, void *doc)
@@ -1497,11 +1500,13 @@ static void ffi_Page_run(js_State *J)
} else {
device = new_js_device(ctx, J);
js_copy(J, 1); /* put the js device on the top so the callbacks know where to get it */
- fz_try(ctx)
+ fz_try(ctx) {
if (no_annots)
fz_run_page_contents(ctx, page, device, &ctm, NULL);
else
fz_run_page(ctx, page, device, &ctm, NULL);
+ fz_close_device(ctx, device);
+ }
fz_always(ctx)
fz_drop_device(ctx, device);
fz_catch(ctx)
@@ -1650,8 +1655,10 @@ static void ffi_Annotation_run(js_State *J)
} else {
device = new_js_device(ctx, J);
js_copy(J, 1); /* put the js device on the top so the callbacks know where to get it */
- fz_try(ctx)
+ fz_try(ctx) {
fz_run_annot(ctx, annot, device, &ctm, NULL);
+ fz_close_device(ctx, device);
+ }
fz_always(ctx)
fz_drop_device(ctx, device);
fz_catch(ctx)
@@ -2213,8 +2220,10 @@ static void ffi_DisplayList_run(js_State *J)
} else {
device = new_js_device(ctx, J);
js_copy(J, 1);
- fz_try(ctx)
+ fz_try(ctx) {
fz_run_display_list(ctx, list, device, &ctm, NULL, NULL);
+ fz_close_device(ctx, device);
+ }
fz_always(ctx)
fz_drop_device(ctx, device);
fz_catch(ctx)
@@ -2418,7 +2427,6 @@ static void ffi_DocumentWriter_endPage(js_State *J)
rethrow(J);
}
-
static void ffi_DocumentWriter_close(js_State *J)
{
fz_context *ctx = js_getcontext(J);