diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-02-24 15:10:09 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-02-24 15:10:09 -0500 |
commit | 744dc2218208790535ff26aad4d07c88026dc63d (patch) | |
tree | 4ca1ce620c11405a9df8bd81eae4fba0731fb0e5 | |
parent | 4a3eac9f139b5697ef454491ac590d75473c96a9 (diff) | |
download | pango-744dc2218208790535ff26aad4d07c88026dc63d.tar.gz |
fc: Fix an ordering issuefontmap-thread-fix
With the recently introduced threading for fontconfig
calls, we introduced an ordering issue where the fontmap
may die before an outstanding thread returns, and then
the code that unrefs the pattern object tries to remove
it from the fontmap cache.
Prevent that by giving each thread a strong ref on the
fontmap while it runs.
Fixes: #537
-rw-r--r-- | pango/pangofc-fontmap.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c index aa90345e..fef3394a 100644 --- a/pango/pangofc-fontmap.c +++ b/pango/pangofc-fontmap.c @@ -800,6 +800,10 @@ static ThreadData * thread_data_new (PangoFcPatterns *patterns) { ThreadData *td; + PangoFcFontMap *fontmap = patterns->fontmap; + + /* We don't want the fontmap dying on us */ + g_object_ref (fontmap); td = g_new (ThreadData, 1); td->patterns = pango_fc_patterns_ref (patterns); @@ -814,12 +818,15 @@ static void thread_data_free (gpointer data) { ThreadData *td = data; + PangoFcFontMap *fontmap = td->patterns->fontmap; g_clear_pointer (&td->fonts, FcFontSetDestroy); FcPatternDestroy (td->pattern); FcConfigDestroy (td->config); pango_fc_patterns_unref (td->patterns); g_free (td); + + g_object_unref (fontmap); } static void |