mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-30 07:14:57 +01:00
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.
This commit is contained in:
parent
7e84b67259
commit
3bc1d819a4
2 changed files with 9 additions and 4 deletions
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue