mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-07 14:55:59 +01:00
Check document health in sc_reload
This hack checks if the PDF file is damaged when zathura tries to automatically reload it. Now even if the document is damaged, zathura does not close the current document session.
This commit is contained in:
parent
e9e39d3a45
commit
27892b7d36
1 changed files with 19 additions and 0 deletions
19
zathura.c
19
zathura.c
|
@ -1554,6 +1554,25 @@ sc_reload(Argument* argument)
|
|||
if(!Zathura.PDF.document)
|
||||
return;
|
||||
|
||||
/* check if file is damaged */
|
||||
char* file_uri = g_filename_to_uri(Zathura.PDF.file, NULL, NULL);
|
||||
if(file_uri)
|
||||
{
|
||||
g_static_mutex_lock(&(Zathura.Lock.pdf_obj_lock));
|
||||
PopplerDocument* temporary_document = NULL;
|
||||
if(!(temporary_document = poppler_document_new_from_file(file_uri, Zathura.PDF.password, NULL)))
|
||||
{
|
||||
g_static_mutex_unlock(&(Zathura.Lock.pdf_obj_lock));
|
||||
g_free(file_uri);
|
||||
return;
|
||||
}
|
||||
g_static_mutex_unlock(&(Zathura.Lock.pdf_obj_lock));
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
g_free(file_uri);
|
||||
|
||||
/* save old information */
|
||||
g_static_mutex_lock(&(Zathura.Lock.pdf_obj_lock));
|
||||
char* path = Zathura.PDF.file ? strdup(Zathura.PDF.file) : NULL;
|
||||
|
|
Loading…
Reference in a new issue