From 9172100d6d9f2f5aa4594aaa130fbfaef7162afd Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Fri, 5 Sep 2014 20:26:41 +0100 Subject: test-device: Abort interpretation when color found. Add a new class of errors and use them to abort interpretation when the test device detects a color page. --- source/tools/mudraw.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'source/tools') diff --git a/source/tools/mudraw.c b/source/tools/mudraw.c index 198e47ce..420ca1dc 100644 --- a/source/tools/mudraw.c +++ b/source/tools/mudraw.c @@ -317,12 +317,22 @@ static void drawpage(fz_context *ctx, fz_document *doc, int pagenum) { int iscolor; dev = fz_new_test_device(ctx, &iscolor, 0.02f); - if (list) - fz_run_display_list(list, dev, &fz_identity, &fz_infinite_rect, NULL); - else - fz_run_page(doc, page, dev, &fz_identity, &cookie); - fz_free_device(dev); - dev = NULL; + fz_try(ctx) + { + if (list) + fz_run_display_list(list, dev, &fz_identity, &fz_infinite_rect, NULL); + else + fz_run_page(doc, page, dev, &fz_identity, &cookie); + } + fz_always(ctx) + { + fz_free_device(dev); + dev = NULL; + } + fz_catch(ctx) + { + fz_rethrow(ctx); + } printf(" %s", iscolor ? "color" : "grayscale"); } -- cgit v1.2.3