Merge branch 'matthiasc/for-main' into 'main'

Plug a memory leak in gsk_render_node_serialize

See merge request GNOME/gtk!6155
This commit is contained in:
Matthias Clasen 2023-06-28 02:42:47 +00:00
commit 25e518326c
5 changed files with 30 additions and 3 deletions

View File

@ -803,6 +803,8 @@ gsk_gl_render_job_untransform_bounds (GskGLRenderJob *job,
out_rect->origin.x -= job->offset_x;
out_rect->origin.y -= job->offset_y;
gsk_transform_unref (transform);
}
static inline void

View File

@ -5703,6 +5703,8 @@ gsk_mask_node_draw (GskRenderNode *node,
cairo_clip (cr);
cairo_mask (cr, mask_pattern);
cairo_pattern_destroy (mask_pattern);
}
static void

View File

@ -2477,6 +2477,15 @@ printer_init (Printer *self,
printer_init_duplicates_for_node (self, node);
}
static void
printer_clear (Printer *self)
{
if (self->str)
g_string_free (self->str, TRUE);
g_hash_table_unref (self->named_nodes);
g_hash_table_unref (self->named_textures);
}
#define IDENT_LEVEL 2 /* Spaces per level */
static void
_indent (Printer *self)
@ -3686,6 +3695,7 @@ GBytes *
gsk_render_node_serialize (GskRenderNode *node)
{
Printer p;
GBytes *res;
printer_init (&p, node);
@ -3705,5 +3715,9 @@ gsk_render_node_serialize (GskRenderNode *node)
render_node_print (&p, node);
}
return g_string_free_to_bytes (p.str);
res = g_string_free_to_bytes (g_steal_pointer (&p.str));
printer_clear (&p);
return res;
}

View File

@ -8,3 +8,4 @@ leak:libgio-2.0.so
leak:libcairo.so
leak:libpixman-1.so
leak:librsvg-2.so
leak:libxkbcommon.so

View File

@ -298,8 +298,12 @@ main (int argc, char **argv)
{
GskRenderNode *node2;
GdkPixbuf *pixbuf, *pixbuf2;
GskTransform *transform;
transform = gsk_transform_scale (NULL, -1, 1);
node2 = gsk_transform_node_new (node, transform);
gsk_transform_unref (transform);
node2 = gsk_transform_node_new (node, gsk_transform_scale (NULL, -1, 1));
save_node (node2, node_file, "-flipped.node");
rendered_texture = gsk_renderer_render_texture (renderer, node2, NULL);
@ -404,8 +408,12 @@ main (int argc, char **argv)
{
GskRenderNode *node2;
GdkPixbuf *pixbuf, *pixbuf2;
GskTransform *transform;
transform = gsk_transform_rotate (NULL, 90);
node2 = gsk_transform_node_new (node, transform);
gsk_transform_unref (transform);
node2 = gsk_transform_node_new (node, gsk_transform_rotate (NULL, 90));
save_node (node2, node_file, "-rotated.node");
rendered_texture = gsk_renderer_render_texture (renderer, node2, NULL);