ector: don't leak cairo context.
authorCedric BAIL <cedric@osg.samsung.com>
Fri, 2 Oct 2015 00:18:54 +0000 (17:18 -0700)
committerCedric BAIL <cedric@osg.samsung.com>
Fri, 2 Oct 2015 00:18:54 +0000 (17:18 -0700)
src/lib/ector/cairo/ector_cairo_private.h
src/lib/ector/cairo/ector_cairo_surface.c
src/modules/evas/engines/software_generic/ector_surface.c

index 5a27708..2b5735a 100644 (file)
@@ -18,8 +18,6 @@ struct _Ector_Cairo_Surface_Data
    struct {
       double x, y;
    } current;
-
-   Eina_Bool internal : 1;
 };
 
 struct _Ector_Renderer_Cairo_Base_Data
index 10fef65..bd44405 100644 (file)
@@ -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;
index 34e957e..ffa3231 100644 (file)
@@ -49,7 +49,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;
 
@@ -60,13 +59,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;
@@ -79,8 +79,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;
@@ -91,7 +90,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));
 }