summaryrefslogtreecommitdiff
path: root/pango/pangoxft-fontmap.c
diff options
context:
space:
mode:
authorAlessandro Pignotti <a.pignotti@sssup.it>2011-05-25 17:04:44 +0200
committerBehdad Esfahbod <behdad@behdad.org>2012-08-27 23:38:17 -0400
commit26bbf750ab0754c113722e87942174cf2953dad4 (patch)
treeef1452c6e594893594820ff31a274e9d62668875 /pango/pangoxft-fontmap.c
parentf81174dd4f8f8601bbf1066ba9757a4a13bb3c60 (diff)
downloadpango-26bbf750ab0754c113722e87942174cf2953dad4.tar.gz
Protect fontmaps with a mutex in pangoxft-fontmap.c
Diffstat (limited to 'pango/pangoxft-fontmap.c')
-rw-r--r--pango/pangoxft-fontmap.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/pango/pangoxft-fontmap.c b/pango/pangoxft-fontmap.c
index 3e6034e9..b8cdf304 100644
--- a/pango/pangoxft-fontmap.c
+++ b/pango/pangoxft-fontmap.c
@@ -65,7 +65,8 @@ static PangoFcFont * pango_xft_font_map_new_font (PangoFcFontMap
FcPattern *pattern);
static void pango_xft_font_map_finalize (GObject *object);
-static GSList *fontmaps = NULL;
+G_LOCK_DEFINE_STATIC (fontmaps);
+static GSList *fontmaps = NULL; /* MT-safe */
G_DEFINE_TYPE (PangoXftFontMap, pango_xft_font_map, PANGO_TYPE_FC_FONT_MAP)
@@ -93,7 +94,9 @@ pango_xft_font_map_finalize (GObject *object)
if (xftfontmap->renderer)
g_object_unref (xftfontmap->renderer);
+ G_LOCK (fontmaps);
fontmaps = g_slist_remove (fontmaps, object);
+ G_UNLOCK (fontmaps);
if (xftfontmap->substitute_destroy)
xftfontmap->substitute_destroy (xftfontmap->substitute_data);
@@ -108,6 +111,7 @@ pango_xft_find_font_map (Display *display,
{
GSList *tmp_list;
+ G_LOCK (fontmaps);
tmp_list = fontmaps;
while (tmp_list)
{
@@ -115,10 +119,14 @@ pango_xft_find_font_map (Display *display,
if (xftfontmap->display == display &&
xftfontmap->screen == screen)
- return PANGO_FONT_MAP (xftfontmap);
+ {
+ G_UNLOCK (fontmaps);
+ return PANGO_FONT_MAP (xftfontmap);
+ }
tmp_list = tmp_list->next;
}
+ G_UNLOCK (fontmaps);
return NULL;
}
@@ -126,7 +134,7 @@ pango_xft_find_font_map (Display *display,
/*
* Hackery to set up notification when a Display is closed
*/
-static GSList *registered_displays;
+static GSList *registered_displays; /* MT-safe, protected by fontmaps lock */
static int
close_display_cb (Display *display,
@@ -134,6 +142,8 @@ close_display_cb (Display *display,
{
GSList *tmp_list;
+ G_LOCK (fontmaps);
+
tmp_list = fontmaps;
while (tmp_list)
{
@@ -146,6 +156,8 @@ close_display_cb (Display *display,
registered_displays = g_slist_remove (registered_displays, display);
+ G_UNLOCK (fontmaps);
+
return 0;
}
@@ -201,10 +213,14 @@ pango_xft_get_font_map (Display *display,
xftfontmap->display = display;
xftfontmap->screen = screen;
+ G_LOCK (fontmaps);
+
register_display (display);
fontmaps = g_slist_prepend (fontmaps, xftfontmap);
+ G_UNLOCK (fontmaps);
+
return PANGO_FONT_MAP (xftfontmap);
}
@@ -231,7 +247,9 @@ pango_xft_shutdown_display (Display *display,
{
PangoXftFontMap *xftfontmap = PANGO_XFT_FONT_MAP (fontmap);
+ G_LOCK (fontmaps);
fontmaps = g_slist_remove (fontmaps, fontmap);
+ G_UNLOCK (fontmaps);
pango_fc_font_map_shutdown (PANGO_FC_FONT_MAP (fontmap));
xftfontmap->display = NULL;