[glib/wip/gapplication] Don't leak memory



commit 13125cdb4081f79e5dc9d2d0a443f8ced3a46843
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jun 5 00:18:23 2010 -0400

    Don't leak memory

 gio/gapplication.c |   34 +++++++++++++++++++++++++++++-----
 1 files changed, 29 insertions(+), 5 deletions(-)
---
diff --git a/gio/gapplication.c b/gio/gapplication.c
index aef72c3..eb2d1ef 100644
--- a/gio/gapplication.c
+++ b/gio/gapplication.c
@@ -841,9 +841,9 @@ g_application_set_property (GObject      *object,
 }
 
 static GObject*
-g_application_constructor  (GType                  type,
-                            guint                  n_construct_properties,
-                            GObjectConstructParam *construct_params)
+g_application_constructor (GType                  type,
+                           guint                  n_construct_properties,
+                           GObjectConstructParam *construct_params)
 {
   GApplication *app;
   GObject *object;
@@ -876,6 +876,28 @@ g_application_constructor  (GType                  type,
 }
 
 static void
+g_application_finalize (GObject *object)
+{
+  GApplication *app = G_APPLICATION (object);
+
+  g_free (app->priv->appid);
+  if (app->priv->actions)
+    g_hash_table_unref (app->priv->actions);
+  if (app->priv->actions_changed_id)
+    g_source_remove (app->priv->actions_changed_id);
+  if (app->priv->mainloop)
+    g_main_loop_unref (app->priv->mainloop);
+
+#ifdef G_OS_UNIX
+  g_free (app->priv->dbus_path);
+  if (app->priv->session_bus)
+    g_object_unref (app->priv->session_bus);
+#endif
+
+  G_OBJECT_CLASS (g_application_parent_class)->finalize (object);
+}
+
+static void
 g_application_class_init (GApplicationClass *klass)
 {
   GObjectClass *gobject_class G_GNUC_UNUSED = G_OBJECT_CLASS (klass);
@@ -885,10 +907,12 @@ g_application_class_init (GApplicationClass *klass)
   gobject_class->constructor = g_application_constructor;
   gobject_class->set_property = g_application_set_property;
   gobject_class->get_property = g_application_get_property;
-  
+
+  gobject_class->finalize = g_application_finalize;
+
   klass->run = g_application_default_run;
   klass->quit = g_application_default_quit;
-  
+
   application_signals[QUIT] =
     g_signal_new (g_intern_static_string ("quit"),
                   G_OBJECT_CLASS_TYPE (klass),



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