[gedit-cossa] Do not leak the window.



commit db9a13fcfc4013e3cc8963dc72a7dd0fe73ae915
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Sat May 28 15:05:38 2011 +0200

    Do not leak the window.

 src/gedit-cossa-plugin.c |   27 +++++++++++++++++++++------
 1 files changed, 21 insertions(+), 6 deletions(-)
---
diff --git a/src/gedit-cossa-plugin.c b/src/gedit-cossa-plugin.c
index 3ef1c90..df8d900 100644
--- a/src/gedit-cossa-plugin.c
+++ b/src/gedit-cossa-plugin.c
@@ -1,5 +1,5 @@
 /*
- * GEdit plugin for GTK+ CSS
+ * gedit plugin for GTK+ CSS
  *
  * ©2011 Carlos Garnacho <carlosg gnome org>
  *
@@ -114,12 +114,27 @@ cossa_plugin_get_property (GObject    *object,
 }
 
 static void
+cossa_plugin_dispose (GObject *object)
+{
+  CossaPluginPrivate *priv = COSSA_PLUGIN (object)->priv;
+
+  if (priv->window != NULL)
+    {
+      g_object_unref (priv->window);
+      priv->window = NULL;
+    }
+
+  G_OBJECT_CLASS (cossa_plugin_parent_class)->dispose (object);
+}
+
+static void
 cossa_plugin_class_init (CossaPluginClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
   object_class->set_property = cossa_plugin_set_property;
   object_class->get_property = cossa_plugin_get_property;
+  object_class->dispose = cossa_plugin_dispose;
 
   g_object_class_override_property (object_class, PROP_WINDOW, "window");
 
@@ -179,13 +194,13 @@ gedit_window_activatable_iface_init (GeditWindowActivatableInterface *iface)
 static gchar *
 get_view_css (GeditView *view)
 {
-    GtkTextBuffer *buffer;
-    GtkTextIter start, end;
+  GtkTextBuffer *buffer;
+  GtkTextIter start, end;
 
-    buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
-    gtk_text_buffer_get_bounds (buffer, &start, &end);
+  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+  gtk_text_buffer_get_bounds (buffer, &start, &end);
 
-    return gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
+  return gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
 }
 
 static void



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