diff --git a/.gitlab-ci/leak-sanitizer.supp b/.gitlab-ci/leak-sanitizer.supp index a5561804..87764945 100644 --- a/.gitlab-ci/leak-sanitizer.supp +++ b/.gitlab-ci/leak-sanitizer.supp @@ -3,3 +3,6 @@ # Cairo internal leaks from weston-keyboard leak:cairo_select_font_face leak:cairo_text_extents + +# Pango thread-global state (not destroyable?) +leak:pango_language_get_default diff --git a/clients/window.c b/clients/window.c index 0f631a0f..52713488 100644 --- a/clients/window.c +++ b/clients/window.c @@ -6063,6 +6063,7 @@ display_destroy(struct display *display) theme_destroy(display->theme); destroy_cursors(display); + cleanup_after_cairo(); if (display->relative_pointer_manager) zwp_relative_pointer_manager_v1_destroy(display->relative_pointer_manager); 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 #ifdef HAVE_PANGO +#include #include #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