summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pango/pangofc-fontmap.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c
index 5be2b815..6e47d08e 100644
--- a/pango/pangofc-fontmap.c
+++ b/pango/pangofc-fontmap.c
@@ -811,6 +811,8 @@ struct _PangoFcFontset
GPtrArray *coverages;
GList *cache_link;
+
+ GMutex lock;
};
typedef PangoFontsetClass PangoFcFontsetClass;
@@ -873,13 +875,21 @@ static PangoFont *
pango_fc_fontset_get_font_at (PangoFcFontset *fontset,
unsigned int i)
{
- while (i >= fontset->fonts->len)
+ /* Meh, mixing atomic and mutexes in a haphazard way... */
+ int len = g_atomic_int_get (&fontset->fonts->len);
+
+ if (i >= len)
{
- PangoFont *font = pango_fc_fontset_load_next_font (fontset);
- g_ptr_array_add (fontset->fonts, font);
- g_ptr_array_add (fontset->coverages, NULL);
- if (!font)
- return NULL;
+ g_mutex_lock (&fontset->lock);
+ while (i >= fontset->fonts->len)
+ {
+ PangoFont *font = pango_fc_fontset_load_next_font (fontset);
+ g_ptr_array_add (fontset->fonts, font);
+ g_ptr_array_add (fontset->coverages, NULL);
+ if (!font)
+ return NULL;
+ }
+ g_mutex_unlock (&fontset->lock);
}
return g_ptr_array_index (fontset->fonts, i);
@@ -933,6 +943,10 @@ pango_fc_fontset_finalize (GObject *object)
if (fontset->patterns)
pango_fc_patterns_unref (fontset->patterns);
+ if (fontset->lock.p) /* Work around bug 686192 */
+ g_mutex_clear (&fontset->lock);
+
+
G_OBJECT_CLASS (pango_fc_fontset_parent_class)->finalize (object);
}