[libchamplain: 42/45] Fix memory management for surfaces in path layer.



commit 105a2e89334cb9c0496934606dcb9d0f829e2d43
Author: Marius Stanciu <stanciumarius94 gmail com>
Date:   Tue Aug 9 19:18:00 2016 +0300

    Fix memory management for surfaces in path layer.

 champlain/champlain-path-layer.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/champlain/champlain-path-layer.c b/champlain/champlain-path-layer.c
index ac19351..a6699c1 100644
--- a/champlain/champlain-path-layer.c
+++ b/champlain/champlain-path-layer.c
@@ -260,6 +260,8 @@ champlain_path_layer_dispose (GObject *object)
     }
 
   g_clear_pointer (&priv->surface, cairo_surface_destroy);
+  g_clear_pointer (&priv->right_surface, cairo_surface_destroy);
+  g_clear_pointer (&priv->left_surface, cairo_surface_destroy);
 
   G_OBJECT_CLASS (champlain_path_layer_parent_class)->dispose (object);
 }
@@ -451,6 +453,10 @@ champlain_path_layer_init (ChamplainPathLayer *self)
   priv->right_canvas = clutter_canvas_new ();
   priv->left_canvas = clutter_canvas_new ();
 
+  priv->surface = NULL;
+  priv->right_surface = NULL;
+  priv->left_surface = NULL;
+
   priv->right_surface_updated = FALSE;
   priv->left_surface_updated = FALSE;
 
@@ -820,6 +826,9 @@ update_surface (ChamplainPathLayer *layer,
       cairo_paint (cr);
 
       set_surface (CHAMPLAIN_EXPORTABLE (layer), new_surface);
+
+      cairo_surface_destroy (new_surface);
+      cairo_destroy (cr);
     }
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]