Don't leak the PangoFontMap we create only for tests

We weren't storing that fontmap at all, so it was re-created an leaked
for every text item (!).

Now we create the fontmap for testing, use it throughout the
duration of the render, and free it when the render is done.
parent 551a3a1c
......@@ -302,14 +302,15 @@ create_font_config_for_testing (RsvgCairoRender *render)
static PangoFontMap *
get_font_map_for_testing (RsvgCairoRender *render)
{
PangoFontMap *font_map;
create_font_config_for_testing (render);
font_map = pango_cairo_font_map_new_for_font_type (CAIRO_FONT_TYPE_FT);
pango_fc_font_map_set_config (PANGO_FC_FONT_MAP (font_map), render->font_config_for_testing);
if (!render->font_map_for_testing) {
render->font_map_for_testing = pango_cairo_font_map_new_for_font_type (CAIRO_FONT_TYPE_FT);
pango_fc_font_map_set_config (PANGO_FC_FONT_MAP (render->font_map_for_testing),
render->font_config_for_testing);
}
return font_map;
return render->font_map_for_testing;
}
PangoContext *
......
......@@ -53,6 +53,11 @@ rsvg_cairo_render_free (RsvgRender * self)
me->font_config_for_testing = NULL;
}
if (me->font_map_for_testing) {
g_object_unref (me->font_map_for_testing);
me->font_map_for_testing = NULL;
}
g_free (me);
}
......@@ -82,6 +87,7 @@ rsvg_cairo_render_new (cairo_t * cr, double width, double height)
cairo_render->bb_stack = NULL;
cairo_render->surfaces_stack = NULL;
cairo_render->font_config_for_testing = NULL;
cairo_render->font_map_for_testing = NULL;
cairo_matrix_init_identity (&matrix);
rsvg_bbox_init (&cairo_render->bbox, &matrix);
......
......@@ -51,6 +51,7 @@ struct _RsvgCairoRender {
GList *surfaces_stack;
FcConfig *font_config_for_testing;
PangoFontMap *font_map_for_testing;
};
#define RSVG_CAIRO_RENDER(render) (_RSVG_RENDER_CIC ((render), RSVG_RENDER_TYPE_CAIRO, RsvgCairoRender))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment