[pango: 1/2] fix thread safety problem
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango: 1/2] fix thread safety problem
- Date: Sun, 31 Jul 2022 23:33:17 +0000 (UTC)
commit 0b110cfc4a1734bfbb6e2084140eefd00db89157
Author: misos1 <michal sudolsky com>
Date: Sun Jul 31 23:33:16 2022 +0000
fix thread safety problem
pango/shape.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/pango/shape.c b/pango/shape.c
index 30bceb800..1ad1f4947 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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]