diff options
Diffstat (limited to 'source/fitz/device.c')
-rw-r--r-- | source/fitz/device.c | 61 |
1 files changed, 34 insertions, 27 deletions
diff --git a/source/fitz/device.c b/source/fitz/device.c index 5d2b7d7e..8a4e3394 100644 --- a/source/fitz/device.c +++ b/source/fitz/device.c @@ -16,33 +16,40 @@ fz_close_device(fz_context *ctx, fz_device *dev) { if (dev == NULL) return; - if (dev->close_device) - dev->close_device(ctx, dev); - - /* Don't call more than once! */ - dev->close_device = NULL; - - /* And disable all further device calls. */ - dev->fill_path = NULL; - dev->stroke_path = NULL; - dev->clip_path = NULL; - dev->clip_stroke_path = NULL; - dev->fill_text = NULL; - dev->stroke_text = NULL; - dev->clip_text = NULL; - dev->clip_stroke_text = NULL; - dev->ignore_text = NULL; - dev->fill_shade = NULL; - dev->fill_image = NULL; - dev->fill_image_mask = NULL; - dev->clip_image_mask = NULL; - dev->pop_clip = NULL; - dev->begin_mask = NULL; - dev->end_mask = NULL; - dev->begin_group = NULL; - dev->end_group = NULL; - dev->begin_tile = NULL; - dev->end_tile = NULL; + + fz_try(ctx) + { + if (dev->close_device) + dev->close_device(ctx, dev); + } + fz_always(ctx) + { + dev->close_device = NULL; /* Don't call more than once! */ + + /* And disable all further device calls. */ + dev->fill_path = NULL; + dev->stroke_path = NULL; + dev->clip_path = NULL; + dev->clip_stroke_path = NULL; + dev->fill_text = NULL; + dev->stroke_text = NULL; + dev->clip_text = NULL; + dev->clip_stroke_text = NULL; + dev->ignore_text = NULL; + dev->fill_shade = NULL; + dev->fill_image = NULL; + dev->fill_image_mask = NULL; + dev->clip_image_mask = NULL; + dev->pop_clip = NULL; + dev->begin_mask = NULL; + dev->end_mask = NULL; + dev->begin_group = NULL; + dev->end_group = NULL; + dev->begin_tile = NULL; + dev->end_tile = NULL; + } + fz_catch(ctx) + fz_rethrow(ctx); } fz_device * |