mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-29 13:35:59 +01:00
Began to set locks for rendering thread
This commit is contained in:
parent
02f646751d
commit
22fea7d281
3 changed files with 20 additions and 8 deletions
|
@ -110,10 +110,7 @@ zathura_document_open(const char* path, const char* password)
|
|||
goto error_free;
|
||||
}
|
||||
|
||||
page->offset = offset;
|
||||
page->number = page_id;
|
||||
page->rendered = false;
|
||||
|
||||
page->offset = offset;
|
||||
offset += page->height;
|
||||
|
||||
document->pages[page_id] = page;
|
||||
|
@ -246,7 +243,7 @@ zathura_document_attachments_free(zathura_list_t* list)
|
|||
}
|
||||
|
||||
zathura_page_t*
|
||||
zathura_page_get(zathura_document_t* document, unsigned int page)
|
||||
zathura_page_get(zathura_document_t* document, unsigned int page_id)
|
||||
{
|
||||
if(!document) {
|
||||
return NULL;
|
||||
|
@ -257,7 +254,15 @@ zathura_page_get(zathura_document_t* document, unsigned int page)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
return document->functions.page_get(document, page);
|
||||
zathura_page_t* page = document->functions.page_get(document, page_id);
|
||||
|
||||
if(page) {
|
||||
page->number = page_id;
|
||||
page->rendered = false;
|
||||
g_static_mutex_init(&(page->lock));
|
||||
}
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -82,6 +82,7 @@ typedef struct zathura_page_s
|
|||
zathura_document_t* document;
|
||||
void* data;
|
||||
bool rendered;
|
||||
GStaticMutex lock;
|
||||
} zathura_page_t;
|
||||
|
||||
struct zathura_document_s
|
||||
|
@ -101,7 +102,7 @@ struct zathura_document_s
|
|||
bool (*document_save_as)(zathura_document_t* document, const char* path);
|
||||
zathura_list_t* (*document_attachments_get)(zathura_document_t* document);
|
||||
|
||||
zathura_page_t* (*page_get)(zathura_document_t* document, unsigned int page);
|
||||
zathura_page_t* (*page_get)(zathura_document_t* document, unsigned int page_id);
|
||||
zathura_list_t* (*page_search_text)(zathura_page_t* page, const char* text);
|
||||
zathura_list_t* (*page_links_get)(zathura_page_t* page);
|
||||
zathura_list_t* (*page_form_fields_get)(zathura_page_t* page);
|
||||
|
@ -120,7 +121,7 @@ bool zathura_document_index_free(zathura_list_t* list);
|
|||
zathura_list_t* zathura_document_attachments_get(zathura_document_t* document);
|
||||
bool zathura_document_attachments_free(zathura_list_t* list);
|
||||
|
||||
zathura_page_t* zathura_page_get(zathura_document_t* document, unsigned int page);
|
||||
zathura_page_t* zathura_page_get(zathura_document_t* document, unsigned int page_id);
|
||||
bool zathura_page_free(zathura_page_t* page);
|
||||
zathura_list_t* zathura_page_search_text(zathura_page_t* page, const char* text);
|
||||
zathura_list_t* zathura_page_links_get(zathura_page_t* page);
|
||||
|
|
6
render.c
6
render.c
|
@ -3,13 +3,17 @@
|
|||
|
||||
bool page_render(zathura_page_t* page)
|
||||
{
|
||||
g_static_mutex_lock(&(page->lock));
|
||||
GtkWidget* image = zathura_page_render(page);
|
||||
g_static_mutex_unlock(&(page->lock));
|
||||
|
||||
if(!image) {
|
||||
printf("error: rendering failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* add new page */
|
||||
g_static_mutex_lock(&(page->lock));
|
||||
GList* list = gtk_container_get_children(GTK_CONTAINER(Zathura.UI.page_view));
|
||||
GtkWidget* widget = (GtkWidget*) g_list_nth_data(list, page->number);
|
||||
g_list_free(list);
|
||||
|
@ -17,6 +21,7 @@ bool page_render(zathura_page_t* page)
|
|||
if(!widget) {
|
||||
printf("error: page container does not exist\n");
|
||||
g_object_unref(image);
|
||||
g_static_mutex_unlock(&(page->lock));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -39,6 +44,7 @@ bool page_render(zathura_page_t* page)
|
|||
|
||||
/* reorder child */
|
||||
gtk_box_reorder_child(GTK_BOX(Zathura.UI.page_view), image, page->number);
|
||||
g_static_mutex_unlock(&(page->lock));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue