diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2012-04-28 18:42:54 +0200 |
---|---|---|
committer | Sebastian Rasmussen <sebras@gmail.com> | 2012-04-28 18:53:00 +0200 |
commit | 2791ae43f075768c65deb9b5c6a37abfebf86d16 (patch) | |
tree | 7f75c4714ed241e7c76c575bc98b8a50de7d71b8 /apps/x11_main.c | |
parent | a90be7a2397b1c9ee846a9fbb0966e0d8e7f7071 (diff) | |
download | mupdf-2791ae43f075768c65deb9b5c6a37abfebf86d16.tar.xz |
Free document/app when document cannot be shown in X11 viewer.
Diffstat (limited to 'apps/x11_main.c')
-rw-r--r-- | apps/x11_main.c | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/apps/x11_main.c b/apps/x11_main.c index 6ab5b43a..941afcfa 100644 --- a/apps/x11_main.c +++ b/apps/x11_main.c @@ -59,6 +59,7 @@ extern void ximage_blit(Drawable d, GC gc, int dstx, int dsty, int srcx, int srcy, int srcw, int srch, int srcstride); void windrawstringxor(pdfapp_t *app, int x, int y, char *s); +void cleanup(pdfapp_t *app); static Display *xdpy; static Atom XA_TARGETS; @@ -100,6 +101,7 @@ static int showingpage = 0; void winerror(pdfapp_t *app, char *msg) { fprintf(stderr, "mupdf: error: %s\n", msg); + cleanup(app); exit(1); } @@ -215,6 +217,27 @@ void winclose(pdfapp_t *app) closing = 1; } +void cleanup(pdfapp_t *app) +{ + fz_context *ctx = app->ctx; + + pdfapp_close(app); + + XDestroyWindow(xdpy, xwin); + + XFreePixmap(xdpy, xicon); + + XFreeCursor(xdpy, xcwait); + XFreeCursor(xdpy, xchand); + XFreeCursor(xdpy, xcarrow); + + XFreeGC(xdpy, xgc); + + XCloseDisplay(xdpy); + + fz_free_context(ctx); +} + static int winresolution() { return DisplayWidth(xdpy, xscr) * 25.4 / @@ -825,21 +848,7 @@ int main(int argc, char **argv) } } - pdfapp_close(&gapp); - - XDestroyWindow(xdpy, xwin); - - XFreePixmap(xdpy, xicon); - - XFreeCursor(xdpy, xcwait); - XFreeCursor(xdpy, xchand); - XFreeCursor(xdpy, xcarrow); - - XFreeGC(xdpy, xgc); - - XCloseDisplay(xdpy); - - fz_free_context(ctx); + cleanup(&gapp); return 0; } |