summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2022-07-31 23:33:16 +0000
committerMatthias Clasen <mclasen@redhat.com>2022-07-31 23:33:16 +0000
commit4b5905aa203884fb0f9c2933dd7ccf08d67fd194 (patch)
treef9f0e18138d53e728ac5c61e190d5a100bf3fd90
parenta05c3549709b92294194c335cb7d5190f14359bf (diff)
parent0b110cfc4a1734bfbb6e2084140eefd00db89157 (diff)
downloadpango-4b5905aa203884fb0f9c2933dd7ccf08d67fd194.tar.gz
Merge branch 'thread_safety_problem' into 'main'
fix thread safety problem Closes #689 See merge request GNOME/pango!634
-rw-r--r--pango/shape.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/pango/shape.c b/pango/shape.c
index 30bceb80..1ad1f494 100644
--- a/pango/shape.c
+++ b/pango/shape.c
@@ -240,16 +240,17 @@ pango_font_get_hb_font_for_context (PangoFont *font,
hb_font = pango_font_get_hb_font (font);
- if (G_UNLIKELY (!funcs))
+ if (G_UNLIKELY (g_once_init_enter (&funcs)))
{
- funcs = hb_font_funcs_create ();
+ hb_font_funcs_t *f = hb_font_funcs_create ();
- hb_font_funcs_set_nominal_glyph_func (funcs, pango_hb_font_get_nominal_glyph, NULL, NULL);
- hb_font_funcs_set_glyph_h_advance_func (funcs, pango_hb_font_get_glyph_h_advance, NULL, NULL);
- hb_font_funcs_set_glyph_v_advance_func (funcs, pango_hb_font_get_glyph_v_advance, NULL, NULL);
- hb_font_funcs_set_glyph_extents_func (funcs, pango_hb_font_get_glyph_extents, NULL, NULL);
+ hb_font_funcs_set_nominal_glyph_func (f, pango_hb_font_get_nominal_glyph, NULL, NULL);
+ hb_font_funcs_set_glyph_h_advance_func (f, pango_hb_font_get_glyph_h_advance, NULL, NULL);
+ hb_font_funcs_set_glyph_v_advance_func (f, pango_hb_font_get_glyph_v_advance, NULL, NULL);
+ hb_font_funcs_set_glyph_extents_func (f, pango_hb_font_get_glyph_extents, NULL, NULL);
- hb_font_funcs_make_immutable (funcs);
+ hb_font_funcs_make_immutable (f);
+ g_once_init_leave (&funcs, f);
}
context->font = font;