diff options
author | Daniel Stone <daniels@collabora.com> | 2022-06-24 12:47:47 +0100 |
---|---|---|
committer | Daniel Stone <daniels@collabora.com> | 2022-06-29 14:33:21 +0100 |
commit | c55a14206db5ac604a8fe4717e9147bbf6407d02 (patch) | |
tree | c0a71cba45d15e8d1b10ca416a34d390cb7012c2 /shared | |
parent | 29c3422e0599236405c8b8507136e07652436bd9 (diff) | |
download | weston-c55a14206db5ac604a8fe4717e9147bbf6407d02.tar.gz |
cairo-util: Clean up more Cairo detritus; almost all of it
Pango, Cairo, and fontconfig, all want to leave thread-global data
hanging around in order to maintain a cache. Try to clean up as much of
it as we possibly can on exit, apart from the Pango language string
which appears to be unfreeable, so has been added to LSan suppressions.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Diffstat (limited to 'shared')
-rw-r--r-- | shared/cairo-util.c | 15 | ||||
-rw-r--r-- | shared/cairo-util.h | 3 | ||||
-rw-r--r-- | shared/meson.build | 5 |
3 files changed, 21 insertions, 2 deletions
diff --git a/shared/cairo-util.c b/shared/cairo-util.c index df4384dc..30670939 100644 --- a/shared/cairo-util.c +++ b/shared/cairo-util.c @@ -40,6 +40,7 @@ #include <libweston/config-parser.h> #ifdef HAVE_PANGO +#include <fontconfig/fontconfig.h> #include <pango/pangocairo.h> #endif @@ -681,3 +682,17 @@ theme_get_location(struct theme *t, int x, int y, return location; } + +/** Cleanup static Cairo/Pango data + * + * Using Cairo, Pango, PangoCairo, and fontconfig, ends up leaving a trail of + * thread-cached data behind us. Clean up what we can. + */ +void +cleanup_after_cairo(void) +{ + cairo_debug_reset_static_data(); +#ifdef HAVE_PANGO + FcFini(); +#endif +} diff --git a/shared/cairo-util.h b/shared/cairo-util.h index 17f7b4f3..a7d4329c 100644 --- a/shared/cairo-util.h +++ b/shared/cairo-util.h @@ -234,4 +234,7 @@ frame_double_touch_up(struct frame *frame, void *data, int32_t id); void frame_repaint(struct frame *frame, cairo_t *cr); +void +cleanup_after_cairo(void); + #endif diff --git a/shared/meson.build b/shared/meson.build index 9b5d7a50..d7936fe5 100644 --- a/shared/meson.build +++ b/shared/meson.build @@ -57,10 +57,11 @@ deps_cairo_shared = [ dep_pango = dependency('pango', required: false) dep_pangocairo = dependency('pangocairo', required: false) +dep_fontconfig = dependency('fontconfig', required: false) dep_glib = dependency('glib-2.0', version: '>= 2.36', required: false) -if dep_pango.found() and dep_pangocairo.found() and dep_glib.found() - deps_cairo_shared += [ dep_pango, dep_pangocairo, dep_glib ] +if dep_pango.found() and dep_pangocairo.found() and dep_fontconfig.found() and dep_glib.found() + deps_cairo_shared += [ dep_pango, dep_pangocairo, dep_fontconfig, dep_glib ] config_h.set('HAVE_PANGO', '1') endif |