cedric pushed a commit to branch efl-1.15. http://git.enlightenment.org/core/efl.git/commit/?id=a2c2b0fa0373d7add8d5e2b2b7362379797dca6c
commit a2c2b0fa0373d7add8d5e2b2b7362379797dca6c Author: Cedric BAIL <ced...@osg.samsung.com> Date: Thu Oct 1 17:18:54 2015 -0700 ector: don't leak cairo context. --- src/lib/ector/cairo/ector_cairo_private.h | 2 -- src/lib/ector/cairo/ector_cairo_surface.c | 10 ++++------ src/modules/evas/engines/software_generic/ector_surface.c | 9 ++++----- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/lib/ector/cairo/ector_cairo_private.h b/src/lib/ector/cairo/ector_cairo_private.h index b5782ff..c41cbe3 100644 --- a/src/lib/ector/cairo/ector_cairo_private.h +++ b/src/lib/ector/cairo/ector_cairo_private.h @@ -18,8 +18,6 @@ struct _Ector_Cairo_Surface_Data struct { double x, y; } current; - - Eina_Bool internal : 1; }; struct _Ector_Renderer_Cairo_Base_Data diff --git a/src/lib/ector/cairo/ector_cairo_surface.c b/src/lib/ector/cairo/ector_cairo_surface.c index 10fef65..bd44405 100644 --- a/src/lib/ector/cairo/ector_cairo_surface.c +++ b/src/lib/ector/cairo/ector_cairo_surface.c @@ -86,13 +86,9 @@ _ector_cairo_surface_context_set(Eo *obj, Ector_Cairo_Surface_Data *pd, cairo_t *ctx) { - if (pd->internal) - { - USE(obj, cairo_destroy, ); + USE(obj, cairo_destroy, ); - if (pd->cairo) cairo_destroy(pd->cairo); - pd->internal = EINA_FALSE; - } + if (pd->cairo) cairo_destroy(pd->cairo); if (!ctx) { USE(obj, cairo_image_surface_create, ); @@ -139,6 +135,8 @@ _ector_cairo_surface_eo_base_destructor(Eo *obj EINA_UNUSED, { eo_do_super(obj, ECTOR_CAIRO_SURFACE_CLASS, eo_destructor()); + + if (--_cairo_count) return ; if (_cairo_so) eina_module_free(_cairo_so); _cairo_so = NULL; diff --git a/src/modules/evas/engines/software_generic/ector_surface.c b/src/modules/evas/engines/software_generic/ector_surface.c index 78ad596..8590768 100644 --- a/src/modules/evas/engines/software_generic/ector_surface.c +++ b/src/modules/evas/engines/software_generic/ector_surface.c @@ -48,7 +48,6 @@ typedef struct _Ector_Cairo_Software_Surface_Data Ector_Cairo_Software_Surface_D struct _Ector_Cairo_Software_Surface_Data { cairo_surface_t *surface; - cairo_t *ctx; void *pixels; @@ -59,13 +58,14 @@ struct _Ector_Cairo_Software_Surface_Data void _ector_cairo_software_surface_surface_set(Eo *obj, Ector_Cairo_Software_Surface_Data *pd, void *pixels, unsigned int width, unsigned int height) { + cairo_t *ctx = NULL; + USE(obj, cairo_image_surface_create_for_data, ); USE(obj, cairo_surface_destroy, ); USE(obj, cairo_create, ); USE(obj, cairo_destroy, ); if (pd->surface) cairo_surface_destroy(pd->surface); pd->surface = NULL; - if (pd->ctx) cairo_destroy(pd->ctx); pd->ctx = NULL; pd->pixels = NULL; pd->width = 0; @@ -78,8 +78,7 @@ _ector_cairo_software_surface_surface_set(Eo *obj, Ector_Cairo_Software_Surface_ width, height, width * sizeof (int)); if (!pd->surface) goto end; - pd->ctx = cairo_create(pd->surface); - if (!pd->ctx) goto end; + ctx = cairo_create(pd->surface); } pd->pixels = pixels; @@ -90,7 +89,7 @@ _ector_cairo_software_surface_surface_set(Eo *obj, Ector_Cairo_Software_Surface_ evas_common_cpu_end_opt(); eo_do(obj, - ector_cairo_surface_context_set(pd->ctx), + ector_cairo_surface_context_set(ctx), ector_surface_size_set(pd->width, pd->height)); } --