[gegl/soc-2012-editor: 23/24] Destroys unused cairo surfaces when new ones are created



commit bcee15e0c68d13b87c36725cf573bf2a37d8d2ff
Author: Isaac Wagner <isaacbw src gnome org>
Date:   Mon Jun 18 15:33:40 2012 -0400

    Destroys unused cairo surfaces when new ones are created

 bin/editor/gegl-editor-layer.c |    1 +
 bin/editor/gegl-node-widget.c  |   12 ++++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/bin/editor/gegl-editor-layer.c b/bin/editor/gegl-editor-layer.c
index 1bebe05..560eb2b 100644
--- a/bin/editor/gegl-editor-layer.c
+++ b/bin/editor/gegl-editor-layer.c
@@ -39,6 +39,7 @@ void refresh_images(GeglEditorLayer* self)
 	cairo_image_surface_create_for_data(buf, CAIRO_FORMAT_ARGB32, 
 				      roi.width, roi.height, 
 				      stride);
+      //            free(buf);
       gegl_editor_set_node_image(self->editor, data->id, image);
     }
 }
diff --git a/bin/editor/gegl-node-widget.c b/bin/editor/gegl-node-widget.c
index 210fdda..13e6d28 100644
--- a/bin/editor/gegl-node-widget.c
+++ b/bin/editor/gegl-node-widget.c
@@ -662,8 +662,16 @@ void gegl_editor_hide_node_image(GeglEditor* self, gint node)
   gegl_editor_get_node(self, node)->show_image = FALSE;
 }
 
-void gegl_editor_set_node_image(GeglEditor* self, gint node, cairo_surface_t* image)
+void gegl_editor_set_node_image(GeglEditor* self, gint node_id, cairo_surface_t* image)
 {
   //TODO: release the old image from memory if it has already been set
-  gegl_editor_get_node(self, node)->image = image;
+  EditorNode* node = gegl_editor_get_node(self, node_id);
+
+  if(node->image != NULL)
+    {
+      cairo_surface_finish(node->image);
+      guchar* buf = cairo_image_surface_get_data(node->image);
+      free(buf);
+    }
+  node->image = image;
 }



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