Commit 3bc1d819 authored by Moritz Lipp's avatar Moritz Lipp

Assign document object iff pages exist

Only saves the document object iff the opened document contains pages. In
addition a check is implemented such that the nrow calculation does not crash.
parent 7e84b672
......@@ -518,8 +518,13 @@ zathura_document_get_document_size(zathura_document_t* document,
{
g_return_if_fail(document != NULL && height != NULL && width != NULL);
const unsigned int npag = zathura_document_get_number_of_pages(document);
const unsigned int ncol = zathura_document_get_pages_per_row(document);
const unsigned int npag = zathura_document_get_number_of_pages(document);
const unsigned int ncol = zathura_document_get_pages_per_row(document);
if (npag == 0 || ncol == 0) {
return;
}
const unsigned int c0 = zathura_document_get_first_page_column(document);
const unsigned int nrow = (npag + c0 - 1 + ncol - 1) / ncol; /* number of rows */
const unsigned int pad = zathura_document_get_page_padding(document);
......
......@@ -791,8 +791,6 @@ document_open(zathura_t* zathura, const char* path, const char* uri, const char*
goto error_out;
}
zathura->document = document;
const char* file_path = zathura_document_get_path(document);
unsigned int number_of_pages = zathura_document_get_number_of_pages(document);
......@@ -802,6 +800,8 @@ document_open(zathura_t* zathura, const char* path, const char* uri, const char*
goto error_free;
}
zathura->document = document;
/* read history file */
zathura_fileinfo_t file_info = {
.current_page = 0,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment