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>
dev
Daniel Stone 2 years ago
parent 29c3422e05
commit c55a14206d
  1. 3
      .gitlab-ci/leak-sanitizer.supp
  2. 1
      clients/window.c
  3. 15
      shared/cairo-util.c
  4. 3
      shared/cairo-util.h
  5. 5
      shared/meson.build

@ -3,3 +3,6 @@
# Cairo internal leaks from weston-keyboard # Cairo internal leaks from weston-keyboard
leak:cairo_select_font_face leak:cairo_select_font_face
leak:cairo_text_extents leak:cairo_text_extents
# Pango thread-global state (not destroyable?)
leak:pango_language_get_default

@ -6063,6 +6063,7 @@ display_destroy(struct display *display)
theme_destroy(display->theme); theme_destroy(display->theme);
destroy_cursors(display); destroy_cursors(display);
cleanup_after_cairo();
if (display->relative_pointer_manager) if (display->relative_pointer_manager)
zwp_relative_pointer_manager_v1_destroy(display->relative_pointer_manager); zwp_relative_pointer_manager_v1_destroy(display->relative_pointer_manager);

@ -40,6 +40,7 @@
#include <libweston/config-parser.h> #include <libweston/config-parser.h>
#ifdef HAVE_PANGO #ifdef HAVE_PANGO
#include <fontconfig/fontconfig.h>
#include <pango/pangocairo.h> #include <pango/pangocairo.h>
#endif #endif
@ -681,3 +682,17 @@ theme_get_location(struct theme *t, int x, int y,
return location; 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
}

@ -234,4 +234,7 @@ frame_double_touch_up(struct frame *frame, void *data, int32_t id);
void void
frame_repaint(struct frame *frame, cairo_t *cr); frame_repaint(struct frame *frame, cairo_t *cr);
void
cleanup_after_cairo(void);
#endif #endif

@ -57,10 +57,11 @@ deps_cairo_shared = [
dep_pango = dependency('pango', required: false) dep_pango = dependency('pango', required: false)
dep_pangocairo = dependency('pangocairo', 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) dep_glib = dependency('glib-2.0', version: '>= 2.36', required: false)
if dep_pango.found() and dep_pangocairo.found() and dep_glib.found() if dep_pango.found() and dep_pangocairo.found() and dep_fontconfig.found() and dep_glib.found()
deps_cairo_shared += [ dep_pango, dep_pangocairo, dep_glib ] deps_cairo_shared += [ dep_pango, dep_pangocairo, dep_fontconfig, dep_glib ]
config_h.set('HAVE_PANGO', '1') config_h.set('HAVE_PANGO', '1')
endif endif

Loading…
Cancel
Save