summaryrefslogtreecommitdiff
path: root/pango/pango-context.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2012-09-01 10:32:21 -0400
committerMatthias Clasen <mclasen@redhat.com>2012-09-01 10:32:21 -0400
commit75c1f008fbc316e5ed3c7ff3e0d2d6d9d770d204 (patch)
tree5b3c2ae123bc87364cdd38b6880a7003157ac73b /pango/pango-context.c
parent22aadf96b8cdd9771c2227fde0c58b6f640e5e3e (diff)
downloadpango-75c1f008fbc316e5ed3c7ff3e0d2d6d9d770d204.tar.gz
Use thread-safe qdata API for caching
GLib gained a new API that allows to set qdata in a thread-safe way. Use it here.
Diffstat (limited to 'pango/pango-context.c')
-rw-r--r--pango/pango-context.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/pango/pango-context.c b/pango/pango-context.c
index 2a100e94..2a1e44f3 100644
--- a/pango/pango-context.c
+++ b/pango/pango-context.c
@@ -594,15 +594,20 @@ get_shaper_font_cache (PangoFontset *fontset)
if (G_UNLIKELY (!cache_quark))
cache_quark = g_quark_from_static_string ("pango-shaper-font-cache");
+retry:
cache = g_object_get_qdata (G_OBJECT (fontset), cache_quark);
- if (!cache)
+ if (G_UNLIKELY (!cache))
{
cache = g_slice_new (ShaperFontCache);
cache->hash = g_hash_table_new_full (g_direct_hash, NULL,
NULL, (GDestroyNotify)shaper_font_element_destroy);
-
- g_object_set_qdata_full (G_OBJECT (fontset), cache_quark,
- cache, (GDestroyNotify)shaper_font_cache_destroy);
+ if (!g_object_replace_qdata (G_OBJECT (fontset), cache_quark, NULL,
+ cache, (GDestroyNotify)shaper_font_cache_destroy,
+ NULL))
+ {
+ shaper_font_cache_destroy (cache);
+ goto retry;
+ }
}
return cache;