diff options
author | Matthias Clasen <mclasen@redhat.com> | 2012-09-01 10:32:21 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2012-09-01 10:32:21 -0400 |
commit | 75c1f008fbc316e5ed3c7ff3e0d2d6d9d770d204 (patch) | |
tree | 5b3c2ae123bc87364cdd38b6880a7003157ac73b /pango/pangocairo-context.c | |
parent | 22aadf96b8cdd9771c2227fde0c58b6f640e5e3e (diff) | |
download | pango-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/pangocairo-context.c')
-rw-r--r-- | pango/pangocairo-context.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/pango/pangocairo-context.c b/pango/pangocairo-context.c index 54cef064..65223b66 100644 --- a/pango/pangocairo-context.c +++ b/pango/pangocairo-context.c @@ -68,6 +68,7 @@ get_context_info (PangoContext *context, if (G_UNLIKELY (!context_info_quark)) context_info_quark = g_quark_from_static_string ("pango-cairo-context-info"); +retry: info = g_object_get_qdata (G_OBJECT (context), context_info_quark); if (G_UNLIKELY (!info) && create) @@ -75,8 +76,13 @@ get_context_info (PangoContext *context, info = g_slice_new0 (PangoCairoContextInfo); info->dpi = -1.0; - g_object_set_qdata_full (G_OBJECT (context), context_info_quark, - info, (GDestroyNotify)free_context_info); + if (!g_object_replace_qdata (G_OBJECT (context), context_info_quark, NULL, + info, (GDestroyNotify)free_context_info, + NULL)) + { + free_context_info (info); + goto retry; + } } return info; |