summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2015-04-04 17:07:07 -0700
committerBehdad Esfahbod <behdad@behdad.org>2015-04-04 17:07:07 -0700
commitef69cbb18b00d7e454cf881a8f58bdabad04ecef (patch)
tree96e548ea7c82d00e2fd7675979eff04afa5abb5b
parent1a767088167b2b71fdc0f8663cd3e1ba7e919862 (diff)
downloadpango-ef69cbb18b00d7e454cf881a8f58bdabad04ecef.tar.gz
Fix MT-unsafe initializations
-rw-r--r--pango/pangocoretext.c4
-rw-r--r--pango/pangofc-font.c4
-rw-r--r--pango/pangoft2-fontmap.c2
-rw-r--r--pango/pangowin32.c9
4 files changed, 10 insertions, 9 deletions
diff --git a/pango/pangocoretext.c b/pango/pangocoretext.c
index dc5769bc..be1d42ee 100644
--- a/pango/pangocoretext.c
+++ b/pango/pangocoretext.c
@@ -172,8 +172,8 @@ pango_core_text_font_find_shaper (PangoFont *font,
guint32 ch)
{
static PangoEngineShape *shaper;
- if (!shaper)
- shaper = g_object_new (pango_core_text_shape_engine_get_type(), NULL); /* XXX MT-unsafe */
+ if (g_once_init_enter (&shaper))
+ g_once_init_leave (&shaper, g_object_new (pango_core_text_shape_engine_get_type(), NULL));
return shaper;
}
diff --git a/pango/pangofc-font.c b/pango/pangofc-font.c
index 79dbbbcf..b463e90c 100644
--- a/pango/pangofc-font.c
+++ b/pango/pangofc-font.c
@@ -342,8 +342,8 @@ pango_fc_font_find_shaper (PangoFont *font G_GNUC_UNUSED,
guint32 ch)
{
static PangoEngineShape *shaper;
- if (!shaper)
- shaper = g_object_new (pango_fc_shape_engine_get_type(), NULL); /* XXX MT-unsafe */
+ if (g_once_init_enter (&shaper))
+ g_once_init_leave (&shaper, g_object_new (pango_fc_shape_engine_get_type(), NULL));
return shaper;
}
diff --git a/pango/pangoft2-fontmap.c b/pango/pangoft2-fontmap.c
index 1904f015..ee27f7f1 100644
--- a/pango/pangoft2-fontmap.c
+++ b/pango/pangoft2-fontmap.c
@@ -311,7 +311,7 @@ PangoFontMap *
pango_ft2_font_map_for_display (void)
{
if (g_once_init_enter (&pango_ft2_global_fontmap))
- g_once_init_leave(&pango_ft2_global_fontmap, PANGO_FT2_FONT_MAP (pango_ft2_font_map_new ()));
+ g_once_init_leave (&pango_ft2_global_fontmap, PANGO_FT2_FONT_MAP (pango_ft2_font_map_new ()));
return PANGO_FONT_MAP (pango_ft2_global_fontmap);
}
diff --git a/pango/pangowin32.c b/pango/pangowin32.c
index 6e2ba260..b6634739 100644
--- a/pango/pangowin32.c
+++ b/pango/pangowin32.c
@@ -156,9 +156,9 @@ _pango_win32_font_init (PangoWin32Font *win32font)
HDC
pango_win32_get_dc (void)
{
- if (_pango_win32_hdc == NULL) /* TODO: MT-unsafe. Use g_once_init/leave */
+ if (g_once_init_enter (&_pango_win32_hdc))
{
- _pango_win32_hdc = CreateDC ("DISPLAY", NULL, NULL, NULL);
+ HDC hdc = CreateDC ("DISPLAY", NULL, NULL, NULL);
memset (&_pango_win32_os_version_info, 0,
sizeof (_pango_win32_os_version_info));
_pango_win32_os_version_info.dwOSVersionInfoSize =
@@ -173,6 +173,7 @@ pango_win32_get_dc (void)
if (getenv ("PANGO_WIN32_DEBUG") != NULL)
_pango_win32_debug = TRUE;
#endif
+ g_once_init_leave (&_pango_win32_hdc, hdc);
}
return _pango_win32_hdc;
@@ -970,8 +971,8 @@ pango_win32_font_find_shaper (PangoFont *font,
guint32 ch)
{
static PangoEngineShape *shaper;
- if (!shaper)
- shaper = g_object_new (pango_win32_shape_engine_get_type(), NULL); /* XXX MT-unsafe */
+ if (g_once_init_enter (&shaper))
+ g_once_init_leave (&shaper, g_object_new (pango_win32_shape_engine_get_type(), NULL));
return shaper;
}