clients/view: Don't try to show inexistant files

dev
Tim Wiederhake 14 years ago committed by Kristian Høgsberg
parent 9aad08e91b
commit 6685aceae3
  1. 16
      clients/view.c

@ -64,8 +64,6 @@ view_draw(struct view *view)
window_get_child_allocation(view->window, &allocation); window_get_child_allocation(view->window, &allocation);
page = poppler_document_get_page(view->document, view->page);
surface = window_get_surface(view->window); surface = window_get_surface(view->window);
cr = cairo_create(surface); cr = cairo_create(surface);
@ -76,6 +74,15 @@ view_draw(struct view *view)
cairo_set_source_rgba(cr, 0, 0, 0, 0.8); cairo_set_source_rgba(cr, 0, 0, 0, 0.8);
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
cairo_paint(cr); cairo_paint(cr);
if(!view->document) {
cairo_destroy(cr);
cairo_surface_destroy(surface);
window_flush(view->window);
return;
}
page = poppler_document_get_page(view->document, view->page);
poppler_page_get_size(page, &width, &height); poppler_page_get_size(page, &width, &height);
doc_aspect = width / height; doc_aspect = width / height;
window_aspect = (double) allocation.width / allocation.height; window_aspect = (double) allocation.width / allocation.height;
@ -119,8 +126,10 @@ view_page_up(struct view *view)
static void static void
view_page_down(struct view *view) view_page_down(struct view *view)
{ {
if(view->page >= poppler_document_get_n_pages(view->document) - 1) if(!view->document ||
view->page >= poppler_document_get_n_pages(view->document) - 1) {
return; return;
}
view->page++; view->page++;
window_schedule_redraw(view->window); window_schedule_redraw(view->window);
@ -215,7 +224,6 @@ view_create(struct display *display, uint32_t key, const char *filename)
if(error) { if(error) {
title = "File not found"; title = "File not found";
view->document = NULL;
} }
view->window = window_create(display, 500, 400); view->window = window_create(display, 500, 400);

Loading…
Cancel
Save