This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository efl.
View the commit online.
commit 067cbd94fef98390fde3e4af3b9d2bd884e56bdc
Author: Cedric BAIL <[email protected]>
AuthorDate: Thu Nov 26 14:02:49 2026 -0600
efl:gfx: free the stroke dash array with the shape that owns it
efl_gfx_shape_stroke_dash_set() keeps its own copy of the dash array
in the shape data, but nothing ever released it: Efl.Gfx.Shape is a
mixin without a destructor, and the classes that own the data only
reset the path in theirs. Every dashed shape leaked its array when
destroyed, the Efl.Canvas.Vg.Shape and the software renderer that
copies it while drawing, and interpolate leaked the temporary array
it hands to dash_set(), which copies it.
The array is released next to the existing path reset, in the owners'
destructors. The GL shape renderer has the same leak for its path and
dash, but its destructor does not chain up at all, which needs its
own fix.
The leak only shows under valgrind (5 dash blocks lost in the VG case
before, none after); the test exercises set, reset, duplicate,
interpolate and drawing of dashed shapes for that run.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
.../ector/software/ector_renderer_software_shape.c | 1 +
src/lib/efl/interfaces/efl_gfx_shape.c | 1 +
src/lib/evas/canvas/efl_canvas_vg_shape.c | 1 +
src/tests/evas/evas_test_vg.c | 65 ++++++++++++++++++++++
4 files changed, 68 insertions(+)
diff --git a/src/lib/ector/software/ector_renderer_software_shape.c b/src/lib/ector/software/ector_renderer_software_shape.c
index c6aa715f52..b177563701 100644
--- a/src/lib/ector/software/ector_renderer_software_shape.c
+++ b/src/lib/ector/software/ector_renderer_software_shape.c
@@ -768,6 +768,7 @@ _ector_renderer_software_shape_efl_object_destructor(Eo *obj, Ector_Renderer_Sof
ector_software_wait(_update_rle, _done_rle, pd->task);
efl_gfx_path_reset(obj);
+ efl_gfx_shape_stroke_dash_set(obj, NULL, 0);
if (pd->shape_data) ector_software_rasterizer_destroy_rle_data(pd->shape_data);
if (pd->outline_data) ector_software_rasterizer_destroy_rle_data(pd->outline_data);
diff --git a/src/lib/efl/interfaces/efl_gfx_shape.c b/src/lib/efl/interfaces/efl_gfx_shape.c
index 787dbac0c1..f4b8f213ab 100644
--- a/src/lib/efl/interfaces/efl_gfx_shape.c
+++ b/src/lib/efl/interfaces/efl_gfx_shape.c
@@ -123,6 +123,7 @@ _efl_gfx_shape_efl_gfx_path_interpolate(Eo *obj, Efl_Gfx_Shape_Data *pd,
efl_gfx_shape_stroke_miterlimit_set(obj, interv);
efl_gfx_shape_stroke_dash_set(obj, dash, property_to.dash_length);
+ free(dash);
efl_gfx_shape_stroke_cap_set(obj, (pos_map < 0.5) ?
property_from.c : property_to.c);
efl_gfx_shape_stroke_join_set(obj, (pos_map < 0.5) ?
diff --git a/src/lib/evas/canvas/efl_canvas_vg_shape.c b/src/lib/evas/canvas/efl_canvas_vg_shape.c
index a698e9aeae..02f0e98773 100644
--- a/src/lib/evas/canvas/efl_canvas_vg_shape.c
+++ b/src/lib/evas/canvas/efl_canvas_vg_shape.c
@@ -156,6 +156,7 @@ _efl_canvas_vg_shape_efl_object_destructor(Eo *obj, Efl_Canvas_Vg_Shape_Data *pd
if (pd->stroke.marker) efl_unref(pd->stroke.marker);
efl_gfx_path_reset(obj);
+ efl_gfx_shape_stroke_dash_set(obj, NULL, 0);
efl_destructor(efl_super(obj, MY_CLASS));
}
diff --git a/src/tests/evas/evas_test_vg.c b/src/tests/evas/evas_test_vg.c
index f5fc8a149a..72e0050475 100644
--- a/src/tests/evas/evas_test_vg.c
+++ b/src/tests/evas/evas_test_vg.c
@@ -256,10 +256,75 @@ EFL_START_TEST(evas_vg_radial_without_solution_pads_to_first_stop)
}
EFL_END_TEST
+// The dash array of a shape is owned by the shape that holds it: a copy, an
+// interpolation and the renderer a draw creates each hold their own, and all
+// of them must be released with their owner. A leak here only shows under
+// valgrind, so the assertions pin the values the API hands back.
+static void
+_build_dashed_shapes(Evas *e)
+{
+ static const Efl_Gfx_Dash dash[] = { { 4, 2 }, { 8, 6 } };
+ static const Efl_Gfx_Dash other[] = { { 8, 6 }, { 16, 10 } };
+ const Efl_Gfx_Dash *got = NULL;
+ unsigned int len = 0;
+ Eo *vg, *from, *to, *dup, *mid;
+
+ vg = efl_add(EFL_CANVAS_VG_OBJECT_CLASS, e);
+ efl_gfx_entity_size_set(vg, EINA_SIZE2D(WIN_W, WIN_H));
+ efl_gfx_entity_visible_set(vg, EINA_TRUE);
+
+ from = efl_add(EFL_CANVAS_VG_SHAPE_CLASS, vg);
+ efl_gfx_path_append_rect(from, 8, 8, 100, 100, 0, 0);
+ efl_gfx_shape_stroke_width_set(from, 4);
+ efl_gfx_shape_stroke_color_set(from, 255, 255, 255, 255);
+ efl_gfx_shape_stroke_dash_set(from, dash, EINA_C_ARRAY_LENGTH(dash));
+ efl_gfx_shape_stroke_dash_set(from, dash, EINA_C_ARRAY_LENGTH(dash));
+
+ to = efl_add(EFL_CANVAS_VG_SHAPE_CLASS, vg);
+ efl_gfx_path_append_rect(to, 8, 8, 100, 100, 0, 0);
+ efl_gfx_shape_stroke_dash_set(to, other, EINA_C_ARRAY_LENGTH(other));
+
+ dup = efl_duplicate(from);
+ efl_gfx_shape_stroke_dash_get(dup, &got, &len);
+ ck_assert_uint_eq(len, 2);
+ ck_assert(got != dash);
+ ck_assert(got[1].gap == 6);
+
+ mid = efl_add(EFL_CANVAS_VG_SHAPE_CLASS, vg);
+ ck_assert(efl_gfx_path_interpolate(mid, from, to, 0.5));
+ efl_gfx_shape_stroke_dash_get(mid, &got, &len);
+ ck_assert_uint_eq(len, 2);
+ ck_assert(got[0].length == 6);
+ ck_assert(got[1].gap == 8);
+
+ efl_gfx_path_copy_from(mid, to);
+ efl_gfx_shape_stroke_dash_get(mid, &got, &len);
+ ck_assert(got[1].length == 16);
+
+ efl_gfx_shape_stroke_dash_set(dup, NULL, 0);
+ efl_gfx_shape_stroke_dash_get(dup, &got, &len);
+ ck_assert_uint_eq(len, 0);
+ ck_assert(!got);
+
+ efl_del(dup);
+ efl_del(mid);
+ efl_canvas_vg_object_root_node_set(vg, from);
+}
+
+EFL_START_TEST(evas_vg_shape_dash_is_released)
+{
+ unsigned int px = 0;
+
+ // Drawing makes the software renderer take its own copy of the dash.
+ _scene_sample("buffer", _build_dashed_shapes, 2, 128, 128, &px);
+}
+EFL_END_TEST
+
void evas_test_vg(TCase *tc)
{
tcase_add_test(tc, evas_vg_mixed_sizes_group_opacity);
tcase_add_test(tc, evas_vg_container_alpha_is_applied);
tcase_add_test(tc, evas_vg_tiny_surface_cache);
tcase_add_test(tc, evas_vg_radial_without_solution_pads_to_first_stop);
+ tcase_add_test(tc, evas_vg_shape_dash_is_released);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.