diff options
author | Robin Watts <robin.watts@artifex.com> | 2013-07-03 16:36:32 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2013-07-03 17:49:31 +0100 |
commit | e433d5c8d2a64d261837c7b25d7378e4ebc1d3d6 (patch) | |
tree | 1607c9d99bc1691d663b96f10fd76b88fa535f1e | |
parent | f191adc1fb899115915b5f0bf41bf32de518bc51 (diff) | |
download | mupdf-e433d5c8d2a64d261837c7b25d7378e4ebc1d3d6.tar.xz |
Update fz_error/fz_warn to output to Debugger window on Win32 too.
Stupid windows debugger doesn't show stdout/stderr anywhere in
non console apps, so add code to make errors/warnings visible.
-rw-r--r-- | source/fitz/error.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/source/fitz/error.c b/source/fitz/error.c index 13ca9c23..fb0dc77e 100644 --- a/source/fitz/error.c +++ b/source/fitz/error.c @@ -1,5 +1,13 @@ #include "mupdf/fitz.h" +#if defined(_WIN32) && !defined(NDEBUG) +#define USE_OUTPUT_DEBUG_STRING +#endif + +#ifdef USE_OUTPUT_DEBUG_STRING +#include <windows.h> +#endif + /* Warning context */ void fz_var_imp(void *var) @@ -26,6 +34,10 @@ void fz_warn(fz_context *ctx, const char *fmt, ...) va_start(ap, fmt); vsnprintf(buf, sizeof buf, fmt, ap); va_end(ap); +#ifdef USE_OUTPUT_DEBUG_STRING + OutputDebugStringA(buf); + OutputDebugStringA("\n"); +#endif if (!strcmp(buf, ctx->warn->message)) { @@ -81,6 +93,11 @@ static void throw(fz_error_context *ex) } else { fprintf(stderr, "uncaught exception: %s\n", ex->message); LOGE("uncaught exception: %s\n", ex->message); +#ifdef USE_OUTPUT_DEBUG_STRING + OutputDebugStringA("uncaught exception: "); + OutputDebugStringA(ex->message); + OutputDebugStringA("\n"); +#endif exit(EXIT_FAILURE); } } @@ -127,6 +144,11 @@ void fz_throw(fz_context *ctx, int code, const char *fmt, ...) fz_flush_warnings(ctx); fprintf(stderr, "error: %s\n", ctx->error->message); LOGE("error: %s\n", ctx->error->message); +#ifdef USE_OUTPUT_DEBUG_STRING + OutputDebugStringA("error: "); + OutputDebugStringA(ctx->error->message); + OutputDebugStringA("\n"); +#endif throw(ctx->error); } @@ -150,6 +172,11 @@ void fz_rethrow_message(fz_context *ctx, const char *fmt, ...) fz_flush_warnings(ctx); fprintf(stderr, "error: %s\n", ctx->error->message); LOGE("error: %s\n", ctx->error->message); +#ifdef USE_OUTPUT_DEBUG_STRING + OutputDebugStringA("error: "); + OutputDebugStringA(ctx->error->message); + OutputDebugStringA("\n"); +#endif throw(ctx->error); } |