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:
Moritz Lipp 2010-06-15 09:39:22 +02:00
parent 321a8dfed9
commit 959fdb56d3

View File

@ -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;