diff options
Diffstat (limited to 'apps/win_main.c')
-rw-r--r-- | apps/win_main.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/apps/win_main.c b/apps/win_main.c index da97b011..3e293957 100644 --- a/apps/win_main.c +++ b/apps/win_main.c @@ -37,6 +37,7 @@ static pdfapp_t gapp; static wchar_t wbuf[1024]; static char filename[1024]; +static fz_context *context; /* * Create registry keys to associate MuPDF with PDF and XPS files. @@ -98,7 +99,7 @@ void winerror(pdfapp_t *app, fz_error error) int i; /* TODO: redirect stderr to a log file and display here */ - fz_catch(error, "displaying error message to user"); + fz_error_handle(error, "displaying error message to user"); fz_strlcpy(msgbuf, "An error has occurred.\n\n", sizeof msgbuf); for (i = 0; i < fz_get_error_count(); i++) @@ -122,7 +123,7 @@ void win32error(char *msg) code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&buf, 0, NULL); - winerror(&gapp, fz_throw("%s:\n%s", msg, buf)); + winerror(&gapp, fz_error_make("%s:\n%s", msg, buf)); } int winfilename(wchar_t *buf, int len) @@ -247,9 +248,9 @@ dloginfoproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) #define SETUCS(ID) \ { \ unsigned short *ucs; \ - ucs = pdf_to_ucs2(obj); \ + ucs = pdf_to_ucs2(xref->ctx, obj); \ SetDlgItemTextW(hwnd, ID, ucs); \ - fz_free(ucs); \ + fz_free(context, ucs); \ } if ((obj = fz_dict_gets(info, "Title"))) @@ -617,7 +618,7 @@ void winreloadfile(pdfapp_t *app) fd = _wopen(wbuf, O_BINARY | O_RDONLY, 0666); if (fd < 0) - winerror(&gapp, fz_throw("cannot reload file '%s'", filename)); + winerror(&gapp, fz_error_make("cannot reload file '%s'", filename)); pdfapp_open(app, filename, fd, 1); } @@ -853,10 +854,17 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShow MSG msg; int fd; int code; + fz_context *ctx; fz_accelerate(); - pdfapp_init(&gapp); + ctx = fz_new_context(&fz_alloc_default); + if (ctx == NULL) + { + fprintf(stderr, "Failed to init context"); + exit(1); + } + pdfapp_init(ctx, &gapp); GetModuleFileNameA(NULL, argv0, sizeof argv0); install_app(argv0); @@ -875,7 +883,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShow fd = _wopen(wbuf, O_BINARY | O_RDONLY, 0666); if (fd < 0) - winerror(&gapp, fz_throw("cannot open file '%s'", filename)); + winerror(&gapp, fz_error_make("cannot open file '%s'", filename)); code = WideCharToMultiByte(CP_UTF8, 0, wbuf, -1, filename, sizeof filename, NULL, NULL); if (code == 0) |