From: Carlos Garcia Campos Date: Mon, 18 Dec 2006 15:26:40 +0000 (+0000) Subject: Use an specific lock for FontConfig. Hopefully it fixes some crashes X-Git-Tag: EVINCE_0_7_0~3 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;ds=sidebyside;h=87db0f592b3ffee3043b4e701be8c8c0132e3520;hp=67f80b85d70a6d577e36c9578b854003a7d910ca;p=evince.git Use an specific lock for FontConfig. Hopefully it fixes some crashes 2006-12-18 Carlos Garcia Campos * backend/ev-document.[ch]: (ev_document_get_fc_mutex), (ev_document_fc_mutex_lock), (ev_document_fc_mutex_unlock): * pdf/ev-poppler.cc: (make_thumbnail_for_size): * shell/ev-jobs.c: (ev_job_render_run), (ev_job_fonts_run): * shell/ev-view.c: (draw_loading_text): * shell/ev-window.c: (ev_window_cmd_file_properties): Use an specific lock for FontConfig. Hopefully it fixes some crashes related to using FontConfig from different threads. --- diff --git a/ChangeLog b/ChangeLog index 0b1ba1ac..52eb6354 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2006-12-18 Carlos Garcia Campos + + * backend/ev-document.[ch]: (ev_document_get_fc_mutex), + (ev_document_fc_mutex_lock), (ev_document_fc_mutex_unlock): + * pdf/ev-poppler.cc: (make_thumbnail_for_size): + * shell/ev-jobs.c: (ev_job_render_run), (ev_job_fonts_run): + * shell/ev-view.c: (draw_loading_text): + * shell/ev-window.c: (ev_window_cmd_file_properties): + + Use an specific lock for FontConfig. Hopefully it fixes some crashes + related to using FontConfig from different threads. + 2006-12-18 Carlos Garcia Campos * shell/ev-view.c: (draw_loading_text): diff --git a/backend/ev-document.c b/backend/ev-document.c index 94647c6b..a951bfa3 100644 --- a/backend/ev-document.c +++ b/backend/ev-document.c @@ -28,6 +28,7 @@ static void ev_document_class_init (gpointer g_class); GMutex *ev_doc_mutex = NULL; +GMutex *ev_fc_mutex = NULL; #define LOG(x) GType @@ -89,7 +90,26 @@ ev_document_doc_mutex_unlock (void) g_mutex_unlock (ev_document_get_doc_mutex ()); } +GMutex * +ev_document_get_fc_mutex (void) +{ + if (ev_fc_mutex == NULL) { + ev_fc_mutex = g_mutex_new (); + } + return ev_fc_mutex; +} +void +ev_document_fc_mutex_lock (void) +{ + g_mutex_lock (ev_document_get_fc_mutex ()); +} + +void +ev_document_fc_mutex_unlock (void) +{ + g_mutex_unlock (ev_document_get_fc_mutex ()); +} gboolean ev_document_load (EvDocument *document, diff --git a/backend/ev-document.h b/backend/ev-document.h index 0da5fc73..828ca256 100644 --- a/backend/ev-document.h +++ b/backend/ev-document.h @@ -97,10 +97,17 @@ struct _EvDocumentIface GType ev_document_get_type (void); GQuark ev_document_error_quark (void); -GMutex *ev_document_get_doc_mutex (void); -void ev_document_doc_mutex_lock (void); + +/* Document mutex */ +GMutex *ev_document_get_doc_mutex (void); +void ev_document_doc_mutex_lock (void); void ev_document_doc_mutex_unlock (void); +/* FontConfig mutex */ +GMutex *ev_document_fc_doc_mutex (void); +void ev_document_fc_mutex_lock (void); +void ev_document_fc_mutex_unlock (void); + EvDocumentInfo *ev_document_get_info (EvDocument *document); gboolean ev_document_load (EvDocument *document, const char *uri, diff --git a/pdf/ev-poppler.cc b/pdf/ev-poppler.cc index d49579e2..d4372ad6 100644 --- a/pdf/ev-poppler.cc +++ b/pdf/ev-poppler.cc @@ -1147,9 +1147,11 @@ make_thumbnail_for_size (PdfDocument *pdf_document, width, height); gdk_pixbuf_fill (pixbuf, 0xffffffff); + ev_document_fc_mutex_lock (); poppler_page_render_to_pixbuf (poppler_page, 0, 0, width, height, scale, rotation, pixbuf); + ev_document_fc_mutex_unlock (); g_object_unref (poppler_page); diff --git a/shell/ev-jobs.c b/shell/ev-jobs.c index 3657f657..e54812c2 100644 --- a/shell/ev-jobs.c +++ b/shell/ev-jobs.c @@ -316,6 +316,8 @@ ev_job_render_run (EvJobRender *job) g_signal_connect (EV_JOB (job)->document, "render_finished", G_CALLBACK (render_finished_cb), job); } else { + ev_document_fc_mutex_lock (); + job->pixbuf = ev_document_render_pixbuf (EV_JOB (job)->document, job->rc); if (job->include_links && EV_IS_DOCUMENT_LINKS (EV_JOB (job)->document)) job->link_mapping = @@ -337,7 +339,8 @@ ev_job_render_run (EvJobRender *job) job->rc, &(job->selection_points)); } - + + ev_document_fc_mutex_unlock (); EV_JOB (job)->finished = TRUE; } @@ -406,7 +409,9 @@ ev_job_fonts_run (EvJobFonts *job) ev_document_doc_mutex_lock (); fonts = EV_DOCUMENT_FONTS (EV_JOB (job)->document); + ev_document_fc_mutex_lock (); job->scan_completed = !ev_document_fonts_scan (fonts, 20); + ev_document_fc_mutex_unlock (); EV_JOB (job)->finished = TRUE; diff --git a/shell/ev-view.c b/shell/ev-view.c index e8bcf0bd..097c97be 100644 --- a/shell/ev-view.c +++ b/shell/ev-view.c @@ -2390,7 +2390,7 @@ draw_loading_text (EvView *view, const char *loading_text = _("Loading..."); - ev_document_doc_mutex_lock (); + ev_document_fc_mutex_lock (); layout = gtk_widget_create_pango_layout (GTK_WIDGET (view), loading_text); @@ -2423,7 +2423,7 @@ draw_loading_text (EvView *view, pango_font_description_free (font_desc); g_object_unref (layout); - ev_document_doc_mutex_unlock (); + ev_document_fc_mutex_unlock (); } static void diff --git a/shell/ev-window.c b/shell/ev-window.c index 19ad581b..2aaff161 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -2086,7 +2086,9 @@ ev_window_cmd_file_properties (GtkAction *action, EvWindow *ev_window) GTK_WINDOW (ev_window)); } + ev_document_fc_mutex_lock (); gtk_widget_show (ev_window->priv->properties); + ev_document_fc_mutex_unlock (); } static void