summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2018-09-25 19:05:35 +0800
committerSebastian Rasmussen <sebras@gmail.com>2018-10-12 15:50:49 +0800
commit03e5c64ecad281f2e0ae3042857cafc952542c7c (patch)
treec852c776c1711b7ac228eeb8f2d18373a9a9e6f5
parent26b29d966ff7a72b5617163298d029c575062f36 (diff)
downloadmupdf-03e5c64ecad281f2e0ae3042857cafc952542c7c.tar.xz
Drop resources in mudraw upon exception.
-rw-r--r--source/tools/mudraw.c702
1 files changed, 356 insertions, 346 deletions
diff --git a/source/tools/mudraw.c b/source/tools/mudraw.c
index ba259e49..c88040b2 100644
--- a/source/tools/mudraw.c
+++ b/source/tools/mudraw.c
@@ -260,7 +260,7 @@ static int band_height = 0;
static int lowmemory = 0;
static int errored = 0;
-static fz_colorspace *colorspace;
+static fz_colorspace *colorspace = NULL;
static fz_colorspace *oi = NULL;
#if FZ_ENABLE_SPOT_RENDERING
static int spots = SPOTS_OVERPRINT_SIM;
@@ -1592,450 +1592,460 @@ int mudraw_main(int argc, char **argv)
exit(1);
}
- if (proof_filename)
- proof_cs = fz_new_icc_colorspace_from_file(ctx, FZ_COLORSPACE_NONE, proof_filename);
+ fz_try(ctx)
+ {
+ if (proof_filename)
+ proof_cs = fz_new_icc_colorspace_from_file(ctx, FZ_COLORSPACE_NONE, proof_filename);
- fz_set_text_aa_level(ctx, alphabits_text);
- fz_set_graphics_aa_level(ctx, alphabits_graphics);
- fz_set_graphics_min_line_width(ctx, min_line_width);
- fz_set_cmm_engine(ctx, icc_engine);
+ fz_set_text_aa_level(ctx, alphabits_text);
+ fz_set_graphics_aa_level(ctx, alphabits_graphics);
+ fz_set_graphics_min_line_width(ctx, min_line_width);
+ fz_set_cmm_engine(ctx, icc_engine);
#ifndef DISABLE_MUTHREADS
- if (bgprint.active)
- {
- int fail = 0;
- bgprint.ctx = fz_clone_context(ctx);
- fail |= mu_create_semaphore(&bgprint.start);
- fail |= mu_create_semaphore(&bgprint.stop);
- fail |= mu_create_thread(&bgprint.thread, bgprint_worker, NULL);
- if (fail)
+ if (bgprint.active)
{
- fprintf(stderr, "bgprint startup failed\n");
- exit(1);
+ int fail = 0;
+ bgprint.ctx = fz_clone_context(ctx);
+ fail |= mu_create_semaphore(&bgprint.start);
+ fail |= mu_create_semaphore(&bgprint.stop);
+ fail |= mu_create_thread(&bgprint.thread, bgprint_worker, NULL);
+ if (fail)
+ {
+ fprintf(stderr, "bgprint startup failed\n");
+ exit(1);
+ }
}
- }
- if (num_workers > 0)
- {
- int i;
- int fail = 0;
- workers = fz_calloc(ctx, num_workers, sizeof(*workers));
- for (i = 0; i < num_workers; i++)
- {
- workers[i].ctx = fz_clone_context(ctx);
- workers[i].num = i;
- fail |= mu_create_semaphore(&workers[i].start);
- fail |= mu_create_semaphore(&workers[i].stop);
- fail |= mu_create_thread(&workers[i].thread, worker_thread, &workers[i]);
- }
- if (fail)
+ if (num_workers > 0)
{
- fprintf(stderr, "worker startup failed\n");
- exit(1);
+ int i;
+ int fail = 0;
+ workers = fz_calloc(ctx, num_workers, sizeof(*workers));
+ for (i = 0; i < num_workers; i++)
+ {
+ workers[i].ctx = fz_clone_context(ctx);
+ workers[i].num = i;
+ fail |= mu_create_semaphore(&workers[i].start);
+ fail |= mu_create_semaphore(&workers[i].stop);
+ fail |= mu_create_thread(&workers[i].thread, worker_thread, &workers[i]);
+ }
+ if (fail)
+ {
+ fprintf(stderr, "worker startup failed\n");
+ exit(1);
+ }
}
- }
#endif /* DISABLE_MUTHREADS */
- if (layout_css)
- {
- fz_buffer *buf = fz_read_file(ctx, layout_css);
- fz_set_user_css(ctx, fz_string_from_buffer(ctx, buf));
- fz_drop_buffer(ctx, buf);
- }
-
- fz_set_use_document_css(ctx, layout_use_doc_css);
+ if (layout_css)
+ {
+ fz_buffer *buf = fz_read_file(ctx, layout_css);
+ fz_set_user_css(ctx, fz_string_from_buffer(ctx, buf));
+ fz_drop_buffer(ctx, buf);
+ }
- /* Determine output type */
- if (band_height < 0)
- {
- fprintf(stderr, "Bandheight must be > 0\n");
- exit(1);
- }
+ fz_set_use_document_css(ctx, layout_use_doc_css);
- output_format = OUT_PNG;
- if (format)
- {
- int i;
+ /* Determine output type */
+ if (band_height < 0)
+ {
+ fprintf(stderr, "Bandheight must be > 0\n");
+ exit(1);
+ }
- for (i = 0; i < nelem(suffix_table); i++)
+ output_format = OUT_PNG;
+ if (format)
{
- if (!strcmp(format, suffix_table[i].suffix+1))
+ int i;
+
+ for (i = 0; i < nelem(suffix_table); i++)
{
- output_format = suffix_table[i].format;
- if (spots == SPOTS_FULL && suffix_table[i].spots == 0)
+ if (!strcmp(format, suffix_table[i].suffix+1))
{
- fprintf(stderr, "Output format '%s' does not support spot rendering.\nDoing overprint simulation instead.\n", suffix_table[i].suffix+1);
- spots = SPOTS_OVERPRINT_SIM;
+ output_format = suffix_table[i].format;
+ if (spots == SPOTS_FULL && suffix_table[i].spots == 0)
+ {
+ fprintf(stderr, "Output format '%s' does not support spot rendering.\nDoing overprint simulation instead.\n", suffix_table[i].suffix+1);
+ spots = SPOTS_OVERPRINT_SIM;
+ }
+ break;
}
- break;
+ }
+ if (i == nelem(suffix_table))
+ {
+ fprintf(stderr, "Unknown output format '%s'\n", format);
+ exit(1);
}
}
- if (i == nelem(suffix_table))
+ else if (output)
{
- fprintf(stderr, "Unknown output format '%s'\n", format);
- exit(1);
- }
- }
- else if (output)
- {
- char *suffix = output;
- int i;
-
- for (i = 0; i < nelem(suffix_table); i++)
- {
- char *s = strstr(suffix, suffix_table[i].suffix);
+ char *suffix = output;
+ int i;
- if (s != NULL)
+ for (i = 0; i < nelem(suffix_table); i++)
{
- suffix = s+1;
- output_format = suffix_table[i].format;
- if (spots == SPOTS_FULL && suffix_table[i].spots == 0)
+ char *s = strstr(suffix, suffix_table[i].suffix);
+
+ if (s != NULL)
{
- fprintf(stderr, "Output format '%s' does not support spot rendering.\nDoing overprint simulation instead.\n", suffix_table[i].suffix+1);
- spots = SPOTS_OVERPRINT_SIM;
+ suffix = s+1;
+ output_format = suffix_table[i].format;
+ if (spots == SPOTS_FULL && suffix_table[i].spots == 0)
+ {
+ fprintf(stderr, "Output format '%s' does not support spot rendering.\nDoing overprint simulation instead.\n", suffix_table[i].suffix+1);
+ spots = SPOTS_OVERPRINT_SIM;
+ }
+ i = 0;
}
- i = 0;
}
}
- }
- if (band_height)
- {
- if (output_format != OUT_PAM && output_format != OUT_PGM && output_format != OUT_PPM && output_format != OUT_PNM && output_format != OUT_PNG && output_format != OUT_PBM && output_format != OUT_PKM && output_format != OUT_PCL && output_format != OUT_PCLM && output_format != OUT_PS && output_format != OUT_PSD && output_format != OUT_TGA)
+ if (band_height)
{
- fprintf(stderr, "Banded operation only possible with PxM, PCL, PCLM, PS, PSD, PNG and TGA outputs\n");
- exit(1);
+ if (output_format != OUT_PAM && output_format != OUT_PGM && output_format != OUT_PPM && output_format != OUT_PNM && output_format != OUT_PNG && output_format != OUT_PBM && output_format != OUT_PKM && output_format != OUT_PCL && output_format != OUT_PCLM && output_format != OUT_PS && output_format != OUT_PSD && output_format != OUT_TGA)
+ {
+ fprintf(stderr, "Banded operation only possible with PxM, PCL, PCLM, PS, PSD, PNG and TGA outputs\n");
+ exit(1);
+ }
+ if (showmd5)
+ {
+ fprintf(stderr, "Banded operation not compatible with MD5\n");
+ exit(1);
+ }
}
- if (showmd5)
+
{
- fprintf(stderr, "Banded operation not compatible with MD5\n");
- exit(1);
- }
- }
+ int i, j;
- {
- int i, j;
+ for (i = 0; i < nelem(format_cs_table); i++)
+ {
+ if (format_cs_table[i].format == output_format)
+ {
+ if (out_cs == CS_UNSET)
+ out_cs = format_cs_table[i].default_cs;
+ for (j = 0; j < nelem(format_cs_table[i].permitted_cs); j++)
+ {
+ if (format_cs_table[i].permitted_cs[j] == out_cs)
+ break;
+ }
+ if (j == nelem(format_cs_table[i].permitted_cs))
+ {
+ fprintf(stderr, "Unsupported colorspace for this format\n");
+ exit(1);
+ }
+ }
+ }
+ }
- for (i = 0; i < nelem(format_cs_table); i++)
+ alpha = 1;
+ switch (out_cs)
{
- if (format_cs_table[i].format == output_format)
- {
- if (out_cs == CS_UNSET)
- out_cs = format_cs_table[i].default_cs;
- for (j = 0; j < nelem(format_cs_table[i].permitted_cs); j++)
+ case CS_MONO:
+ case CS_GRAY:
+ case CS_GRAY_ALPHA:
+ colorspace = fz_device_gray(ctx);
+ alpha = (out_cs == CS_GRAY_ALPHA);
+ break;
+ case CS_RGB:
+ case CS_RGB_ALPHA:
+ colorspace = fz_device_rgb(ctx);
+ alpha = (out_cs == CS_RGB_ALPHA);
+ break;
+ case CS_CMYK:
+ case CS_CMYK_ALPHA:
+ colorspace = fz_device_cmyk(ctx);
+ alpha = (out_cs == CS_CMYK_ALPHA);
+ break;
+ case CS_ICC:
+ fz_try(ctx)
+ colorspace = fz_new_icc_colorspace_from_file(ctx, FZ_COLORSPACE_NONE, icc_filename);
+ fz_catch(ctx)
{
- if (format_cs_table[i].permitted_cs[j] == out_cs)
- break;
+ fprintf(stderr, "Invalid ICC destination color space\n");
+ exit(1);
}
- if (j == nelem(format_cs_table[i].permitted_cs))
+ if (colorspace == NULL)
{
- fprintf(stderr, "Unsupported colorspace for this format\n");
+ fprintf(stderr, "Invalid ICC destination color space\n");
exit(1);
}
- }
+ alpha = 0;
+ break;
+ default:
+ fprintf(stderr, "Unknown colorspace!\n");
+ exit(1);
+ break;
}
- }
- alpha = 1;
- switch (out_cs)
- {
- case CS_MONO:
- case CS_GRAY:
- case CS_GRAY_ALPHA:
- colorspace = fz_device_gray(ctx);
- alpha = (out_cs == CS_GRAY_ALPHA);
- break;
- case CS_RGB:
- case CS_RGB_ALPHA:
- colorspace = fz_device_rgb(ctx);
- alpha = (out_cs == CS_RGB_ALPHA);
- break;
- case CS_CMYK:
- case CS_CMYK_ALPHA:
- colorspace = fz_device_cmyk(ctx);
- alpha = (out_cs == CS_CMYK_ALPHA);
- break;
- case CS_ICC:
- fz_try(ctx)
- colorspace = fz_new_icc_colorspace_from_file(ctx, FZ_COLORSPACE_NONE, icc_filename);
- fz_catch(ctx)
- {
- fprintf(stderr, "Invalid ICC destination color space\n");
- exit(1);
- }
- if (colorspace == NULL)
+ if (out_cs != CS_ICC)
+ colorspace = fz_keep_colorspace(ctx, colorspace);
+ else
{
- fprintf(stderr, "Invalid ICC destination color space\n");
- exit(1);
- }
- alpha = 0;
- break;
- default:
- fprintf(stderr, "Unknown colorspace!\n");
- exit(1);
- break;
- }
-
- if (out_cs != CS_ICC)
- colorspace = fz_keep_colorspace(ctx, colorspace);
- else
- {
- int i, j, okay;
+ int i, j, okay;
- /* Check to make sure this icc profile is ok with the output format */
- okay = 0;
- for (i = 0; i < nelem(format_cs_table); i++)
- {
- if (format_cs_table[i].format == output_format)
+ /* Check to make sure this icc profile is ok with the output format */
+ okay = 0;
+ for (i = 0; i < nelem(format_cs_table); i++)
{
- for (j = 0; j < nelem(format_cs_table[i].permitted_cs); j++)
+ if (format_cs_table[i].format == output_format)
{
- switch (format_cs_table[i].permitted_cs[j])
+ for (j = 0; j < nelem(format_cs_table[i].permitted_cs); j++)
{
- case CS_MONO:
- case CS_GRAY:
- case CS_GRAY_ALPHA:
- if (fz_colorspace_is_gray(ctx, colorspace))
- okay = 1;
- break;
- case CS_RGB:
- case CS_RGB_ALPHA:
- if (fz_colorspace_is_rgb(ctx, colorspace))
- okay = 1;
- break;
- case CS_CMYK:
- case CS_CMYK_ALPHA:
- if (fz_colorspace_is_cmyk(ctx, colorspace))
- okay = 1;
- break;
+ switch (format_cs_table[i].permitted_cs[j])
+ {
+ case CS_MONO:
+ case CS_GRAY:
+ case CS_GRAY_ALPHA:
+ if (fz_colorspace_is_gray(ctx, colorspace))
+ okay = 1;
+ break;
+ case CS_RGB:
+ case CS_RGB_ALPHA:
+ if (fz_colorspace_is_rgb(ctx, colorspace))
+ okay = 1;
+ break;
+ case CS_CMYK:
+ case CS_CMYK_ALPHA:
+ if (fz_colorspace_is_cmyk(ctx, colorspace))
+ okay = 1;
+ break;
+ }
}
}
}
- }
- if (!okay)
- {
- fprintf(stderr, "ICC profile uses a colorspace that cannot be used for this format\n");
- exit(1);
+ if (!okay)
+ {
+ fprintf(stderr, "ICC profile uses a colorspace that cannot be used for this format\n");
+ exit(1);
+ }
}
- }
#if FZ_ENABLE_PDF
- if (output_format == OUT_PDF)
- {
- pdfout = pdf_create_document(ctx);
- }
- else
-#endif
- if (output_format == OUT_GPROOF)
- {
- /* GPROOF files are saved direct. Do not open "output". */
- if (!output)
- fz_throw(ctx, FZ_ERROR_GENERIC, "output filename required when saving GProof file");
- }
- else if (output_format == OUT_SVG)
- {
- /* SVG files are always opened for each page. Do not open "output". */
- }
- else if (output && (output[0] != '-' || output[1] != 0) && *output != 0)
- {
- if (has_percent_d(output))
- output_file_per_page = 1;
+ if (output_format == OUT_PDF)
+ {
+ pdfout = pdf_create_document(ctx);
+ }
else
- out = fz_new_output_with_path(ctx, output, 0);
- }
- else
- {
+#endif
+ if (output_format == OUT_GPROOF)
+ {
+ /* GPROOF files are saved direct. Do not open "output". */
+ if (!output)
+ fz_throw(ctx, FZ_ERROR_GENERIC, "output filename required when saving GProof file");
+ }
+ else if (output_format == OUT_SVG)
+ {
+ /* SVG files are always opened for each page. Do not open "output". */
+ }
+ else if (output && (output[0] != '-' || output[1] != 0) && *output != 0)
+ {
+ if (has_percent_d(output))
+ output_file_per_page = 1;
+ else
+ out = fz_new_output_with_path(ctx, output, 0);
+ }
+ else
+ {
#ifdef _WIN32
- /* Windows specific code to make stdout binary. */
- if (output_format != OUT_TEXT && output_format != OUT_STEXT && output_format != OUT_HTML && output_format != OUT_XHTML && output_format != OUT_TRACE)
- setmode(fileno(stdout), O_BINARY);
+ /* Windows specific code to make stdout binary. */
+ if (output_format != OUT_TEXT && output_format != OUT_STEXT && output_format != OUT_HTML && output_format != OUT_XHTML && output_format != OUT_TRACE)
+ setmode(fileno(stdout), O_BINARY);
#endif
- out = fz_stdout(ctx);
- }
-
- if (!output_file_per_page)
- file_level_headers(ctx);
+ out = fz_stdout(ctx);
+ }
- timing.count = 0;
- timing.total = 0;
- timing.min = 1 << 30;
- timing.max = 0;
- timing.mininterp = 1 << 30;
- timing.maxinterp = 0;
- timing.minpage = 0;
- timing.maxpage = 0;
- timing.minfilename = "";
- timing.maxfilename = "";
- if (showtime && bgprint.active)
- timing.total = gettime();
+ if (!output_file_per_page)
+ file_level_headers(ctx);
+
+ timing.count = 0;
+ timing.total = 0;
+ timing.min = 1 << 30;
+ timing.max = 0;
+ timing.mininterp = 1 << 30;
+ timing.maxinterp = 0;
+ timing.minpage = 0;
+ timing.maxpage = 0;
+ timing.minfilename = "";
+ timing.maxfilename = "";
+ if (showtime && bgprint.active)
+ timing.total = gettime();
- fz_try(ctx)
- {
- fz_register_document_handlers(ctx);
-
- while (fz_optind < argc)
+ fz_try(ctx)
{
- fz_try(ctx)
+ fz_register_document_handlers(ctx);
+
+ while (fz_optind < argc)
{
- filename = argv[fz_optind++];
- files++;
+ fz_try(ctx)
+ {
+ filename = argv[fz_optind++];
+ files++;
- doc = fz_open_document(ctx, filename);
+ doc = fz_open_document(ctx, filename);
- /* Once document is open check for output intent colorspace */
- oi = fz_document_output_intent(ctx, doc);
- if (oi)
- {
- /* See if we had explicitly set a profile to render */
- if (out_cs != CS_ICC)
+ /* Once document is open check for output intent colorspace */
+ oi = fz_document_output_intent(ctx, doc);
+ if (oi)
{
- /* In this case, we want to render to the output intent
- * color space if the number of channels is the same */
- if (fz_colorspace_n(ctx, oi) == fz_colorspace_n(ctx, colorspace))
+ /* See if we had explicitly set a profile to render */
+ if (out_cs != CS_ICC)
{
- fz_drop_colorspace(ctx, colorspace);
- colorspace = fz_keep_colorspace(ctx, oi);
+ /* In this case, we want to render to the output intent
+ * color space if the number of channels is the same */
+ if (fz_colorspace_n(ctx, oi) == fz_colorspace_n(ctx, colorspace))
+ {
+ fz_drop_colorspace(ctx, colorspace);
+ colorspace = fz_keep_colorspace(ctx, oi);
+ }
}
}
- }
- if (fz_needs_password(ctx, doc))
- {
- if (!fz_authenticate_password(ctx, doc, password))
- fz_throw(ctx, FZ_ERROR_GENERIC, "cannot authenticate password: %s", filename);
- }
+ if (fz_needs_password(ctx, doc))
+ {
+ if (!fz_authenticate_password(ctx, doc, password))
+ fz_throw(ctx, FZ_ERROR_GENERIC, "cannot authenticate password: %s", filename);
+ }
- fz_layout_document(ctx, doc, layout_w, layout_h, layout_em);
+ fz_layout_document(ctx, doc, layout_w, layout_h, layout_em);
- if (layer_config)
- apply_layer_config(ctx, doc, layer_config);
+ if (layer_config)
+ apply_layer_config(ctx, doc, layer_config);
- if (output_format == OUT_GPROOF)
- {
- fz_save_gproof(ctx, filename, doc, output, resolution, "", "");
+ if (output_format == OUT_GPROOF)
+ {
+ fz_save_gproof(ctx, filename, doc, output, resolution, "", "");
+ }
+ else
+ {
+ if (fz_optind == argc || !fz_is_page_range(ctx, argv[fz_optind]))
+ drawrange(ctx, doc, "1-N");
+ if (fz_optind < argc && fz_is_page_range(ctx, argv[fz_optind]))
+ drawrange(ctx, doc, argv[fz_optind++]);
+ }
+
+ bgprint_flush();
+ fz_drop_document(ctx, doc);
+ doc = NULL;
}
- else
+ fz_catch(ctx)
{
- if (fz_optind == argc || !fz_is_page_range(ctx, argv[fz_optind]))
- drawrange(ctx, doc, "1-N");
- if (fz_optind < argc && fz_is_page_range(ctx, argv[fz_optind]))
- drawrange(ctx, doc, argv[fz_optind++]);
- }
+ fz_drop_document(ctx, doc);
+ doc = NULL;
- bgprint_flush();
- fz_drop_document(ctx, doc);
- doc = NULL;
- }
- fz_catch(ctx)
- {
- fz_drop_document(ctx, doc);
- doc = NULL;
-
- if (!ignore_errors)
- fz_rethrow(ctx);
+ if (!ignore_errors)
+ fz_rethrow(ctx);
- bgprint_flush();
- fz_warn(ctx, "ignoring error in '%s'", filename);
+ bgprint_flush();
+ fz_warn(ctx, "ignoring error in '%s'", filename);
+ }
}
}
- }
- fz_catch(ctx)
- {
- bgprint_flush();
- fz_drop_document(ctx, doc);
- fprintf(stderr, "error: cannot draw '%s'\n", filename);
- errored = 1;
- }
+ fz_catch(ctx)
+ {
+ bgprint_flush();
+ fz_drop_document(ctx, doc);
+ fprintf(stderr, "error: cannot draw '%s'\n", filename);
+ errored = 1;
+ }
- if (!output_file_per_page)
- file_level_trailers(ctx);
+ if (!output_file_per_page)
+ file_level_trailers(ctx);
#if FZ_ENABLE_PDF
- if (output_format == OUT_PDF)
- {
- if (!output)
- output = "out.pdf";
- pdf_save_document(ctx, pdfout, output, NULL);
- pdf_drop_document(ctx, pdfout);
- }
- else
+ if (output_format == OUT_PDF)
+ {
+ if (!output)
+ output = "out.pdf";
+ pdf_save_document(ctx, pdfout, output, NULL);
+ pdf_drop_document(ctx, pdfout);
+ }
+ else
#endif
- if (output_format == OUT_GPROOF || output_format == OUT_SVG)
- {
- /* No output file to close */
- }
- else
- {
- fz_close_output(ctx, out);
- fz_drop_output(ctx, out);
- out = NULL;
- }
-
- if (showtime && timing.count > 0)
- {
- if (bgprint.active)
- timing.total = gettime() - timing.total;
+ if (output_format == OUT_GPROOF || output_format == OUT_SVG)
+ {
+ /* No output file to close */
+ }
+ else
+ {
+ fz_close_output(ctx, out);
+ fz_drop_output(ctx, out);
+ out = NULL;
+ }
- if (files == 1)
+ if (showtime && timing.count > 0)
{
- fprintf(stderr, "total %dms / %d pages for an average of %dms\n",
- timing.total, timing.count, timing.total / timing.count);
if (bgprint.active)
+ timing.total = gettime() - timing.total;
+
+ if (files == 1)
{
- fprintf(stderr, "fastest page %d: %dms (interpretation) %dms (rendering) %dms(total)\n",
- timing.minpage, timing.mininterp, timing.min - timing.mininterp, timing.min);
- fprintf(stderr, "slowest page %d: %dms (interpretation) %dms (rendering) %dms(total)\n",
- timing.maxpage, timing.maxinterp, timing.max - timing.maxinterp, timing.max);
+ fprintf(stderr, "total %dms / %d pages for an average of %dms\n",
+ timing.total, timing.count, timing.total / timing.count);
+ if (bgprint.active)
+ {
+ fprintf(stderr, "fastest page %d: %dms (interpretation) %dms (rendering) %dms(total)\n",
+ timing.minpage, timing.mininterp, timing.min - timing.mininterp, timing.min);
+ fprintf(stderr, "slowest page %d: %dms (interpretation) %dms (rendering) %dms(total)\n",
+ timing.maxpage, timing.maxinterp, timing.max - timing.maxinterp, timing.max);
+ }
+ else
+ {
+ fprintf(stderr, "fastest page %d: %dms\n", timing.minpage, timing.min);
+ fprintf(stderr, "slowest page %d: %dms\n", timing.maxpage, timing.max);
+ }
}
else
{
- fprintf(stderr, "fastest page %d: %dms\n", timing.minpage, timing.min);
- fprintf(stderr, "slowest page %d: %dms\n", timing.maxpage, timing.max);
+ fprintf(stderr, "total %dms / %d pages for an average of %dms in %d files\n",
+ timing.total, timing.count, timing.total / timing.count, files);
+ fprintf(stderr, "fastest page %d: %dms (%s)\n", timing.minpage, timing.min, timing.minfilename);
+ fprintf(stderr, "slowest page %d: %dms (%s)\n", timing.maxpage, timing.max, timing.maxfilename);
}
}
- else
+
+#ifndef DISABLE_MUTHREADS
+ if (num_workers > 0)
{
- fprintf(stderr, "total %dms / %d pages for an average of %dms in %d files\n",
- timing.total, timing.count, timing.total / timing.count, files);
- fprintf(stderr, "fastest page %d: %dms (%s)\n", timing.minpage, timing.min, timing.minfilename);
- fprintf(stderr, "slowest page %d: %dms (%s)\n", timing.maxpage, timing.max, timing.maxfilename);
+ int i;
+ for (i = 0; i < num_workers; i++)
+ {
+ workers[i].band = -1;
+ mu_trigger_semaphore(&workers[i].start);
+ mu_wait_semaphore(&workers[i].stop);
+ mu_destroy_semaphore(&workers[i].start);
+ mu_destroy_semaphore(&workers[i].stop);
+ mu_destroy_thread(&workers[i].thread);
+ fz_drop_context(workers[i].ctx);
+ }
+ fz_free(ctx, workers);
}
- }
-#ifndef DISABLE_MUTHREADS
- if (num_workers > 0)
- {
- int i;
- for (i = 0; i < num_workers; i++)
+ if (bgprint.active)
{
- workers[i].band = -1;
- mu_trigger_semaphore(&workers[i].start);
- mu_wait_semaphore(&workers[i].stop);
- mu_destroy_semaphore(&workers[i].start);
- mu_destroy_semaphore(&workers[i].stop);
- mu_destroy_thread(&workers[i].thread);
- fz_drop_context(workers[i].ctx);
+ bgprint.pagenum = -1;
+ mu_trigger_semaphore(&bgprint.start);
+ mu_wait_semaphore(&bgprint.stop);
+ mu_destroy_semaphore(&bgprint.start);
+ mu_destroy_semaphore(&bgprint.stop);
+ mu_destroy_thread(&bgprint.thread);
+ fz_drop_context(bgprint.ctx);
}
- fz_free(ctx, workers);
+#endif /* DISABLE_MUTHREADS */
}
-
- if (bgprint.active)
+ fz_always(ctx)
+ {
+ fz_drop_colorspace(ctx, colorspace);
+ fz_drop_colorspace(ctx, proof_cs);
+ }
+ fz_catch(ctx)
{
- bgprint.pagenum = -1;
- mu_trigger_semaphore(&bgprint.start);
- mu_wait_semaphore(&bgprint.stop);
- mu_destroy_semaphore(&bgprint.start);
- mu_destroy_semaphore(&bgprint.stop);
- mu_destroy_thread(&bgprint.thread);
- fz_drop_context(bgprint.ctx);
}
-#endif /* DISABLE_MUTHREADS */
- fz_drop_colorspace(ctx, colorspace);
- fz_drop_colorspace(ctx, proof_cs);
fz_drop_context(ctx);
+
#ifndef DISABLE_MUTHREADS
fin_mudraw_locks();
#endif /* DISABLE_MUTHREADS */