[gimp] app: don't leak options->language; add finalize() to free it



commit 94e757df51ac3ed14683fdd6ed10d65ba231dac8
Author: Michael Natterer <mitch gimp org>
Date:   Tue Jun 22 23:04:23 2010 +0200

    app: don't leak options->language; add finalize() to free it

 app/tools/gimptextoptions.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/app/tools/gimptextoptions.c b/app/tools/gimptextoptions.c
index 8aa578e..c529bda 100644
--- a/app/tools/gimptextoptions.c
+++ b/app/tools/gimptextoptions.c
@@ -70,6 +70,7 @@ enum
 };
 
 
+static void  gimp_text_options_finalize           (GObject      *object);
 static void  gimp_text_options_set_property       (GObject      *object,
                                                    guint         property_id,
                                                    const GValue *value,
@@ -98,12 +99,15 @@ G_DEFINE_TYPE_WITH_CODE (GimpTextOptions, gimp_text_options,
                          G_IMPLEMENT_INTERFACE (GIMP_TYPE_RECTANGLE_OPTIONS,
                                                 NULL))
 
+#define parent_class gimp_text_options_parent_class
+
 
 static void
 gimp_text_options_class_init (GimpTextOptionsClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
+  object_class->finalize     = gimp_text_options_finalize;
   object_class->set_property = gimp_text_options_set_property;
   object_class->get_property = gimp_text_options_get_property;
 
@@ -207,6 +211,20 @@ gimp_text_options_init (GimpTextOptions *options)
 }
 
 static void
+gimp_text_options_finalize (GObject *object)
+{
+  GimpTextOptions *options = GIMP_TEXT_OPTIONS (object);
+
+  if (options->language)
+    {
+      g_free (options->language);
+      options->language = NULL;
+    }
+
+  G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
 gimp_text_options_get_property (GObject    *object,
                                 guint       property_id,
                                 GValue     *value,



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