[goffice] Canvas: plug leak.



commit 0cc8e93e1d8a6b0ed00716a624cb3d5d46fcccd9
Author: Morten Welinder <terra gnome org>
Date:   Wed Sep 16 10:31:23 2009 -0400

    Canvas: plug leak.

 ChangeLog                    |    5 +++++
 goffice/canvas/goc-polygon.c |   16 +++++++++++++++-
 2 files changed, 20 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 40caf23..054157d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-09-16  Morten Welinder  <terra gnome org>
+
+	* goffice/canvas/goc-polygon.c (goc_polygon_finalize): New
+	function to plug leak.
+
 2009-09-15  Morten Welinder  <terra gnome org>
 
 	* goffice/canvas/goc-group.c (goc_group_clear): Add sanity check.
diff --git a/goffice/canvas/goc-polygon.c b/goffice/canvas/goc-polygon.c
index 233ec8e..0784ee7 100644
--- a/goffice/canvas/goc-polygon.c
+++ b/goffice/canvas/goc-polygon.c
@@ -30,9 +30,19 @@ enum {
 	POLYGON_PROP_SPLINE
 };
 
+static GocStyledItemClass *parent_class;
+
+static void
+goc_polygon_finalize (GObject *obj)
+{
+	GocPolygon *polygon = GOC_POLYGON (obj);
+	g_free (polygon->points);
+	((GObjectClass *) parent_class)->finalize (obj);
+}
+
 static void
 goc_polygon_set_property (GObject *gobject, guint param_id,
-				    GValue const *value, GParamSpec *pspec)
+			  GValue const *value, GParamSpec *pspec)
 {
 	GocPolygon *polygon = GOC_POLYGON (gobject);
 
@@ -218,10 +228,14 @@ goc_polygon_class_init (GocItemClass *item_klass)
 	GObjectClass *obj_klass = (GObjectClass *) item_klass;
 	GocStyledItemClass *gsi_klass = (GocStyledItemClass *) item_klass;
 
+	parent_class = g_type_class_peek_parent (item_klass);
+
 	gsi_klass->init_style = goc_polygon_init_style;
 
 	obj_klass->get_property = goc_polygon_get_property;
 	obj_klass->set_property = goc_polygon_set_property;
+	obj_klass->finalize = goc_polygon_finalize;
+
         g_object_class_install_property (obj_klass, POLYGON_PROP_POINTS,
                  g_param_spec_boxed ("points", _("points"), _("The polygon vertices"),
 				     GOC_TYPE_POINTS,



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