[gtksourceview] Do not ref the buffer, weak ref instead.



commit 4be14cc1bc5008f9ecb02a3ab63697f46879ad85
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Tue Mar 16 19:20:03 2010 +0100

    Do not ref the buffer, weak ref instead.

 gtksourceview/gtksourceundomanagerdefault.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/gtksourceview/gtksourceundomanagerdefault.c b/gtksourceview/gtksourceundomanagerdefault.c
index db7d03e..4961d22 100644
--- a/gtksourceview/gtksourceundomanagerdefault.c
+++ b/gtksourceview/gtksourceundomanagerdefault.c
@@ -219,6 +219,13 @@ clear_undo (GtkSourceUndoManagerDefault *manager)
 }
 
 static void
+buffer_notify (GtkSourceUndoManagerDefault *manager,
+               gpointer                     where_the_object_was)
+{
+	manager->priv->buffer = NULL;
+}
+
+static void
 set_buffer (GtkSourceUndoManagerDefault *manager,
             GtkTextBuffer               *buffer)
 {
@@ -239,13 +246,18 @@ set_buffer (GtkSourceUndoManagerDefault *manager,
 			                             manager->priv->buffer_signals[i]);
 		}
 
-		g_object_unref (manager->priv->buffer);
+		g_object_weak_unref (G_OBJECT (manager->priv->buffer),
+		                     (GWeakNotify)buffer_notify,
+		                     manager);
 		manager->priv->buffer = NULL;
 	}
 
 	if (buffer != NULL)
 	{
-		manager->priv->buffer = g_object_ref (buffer);
+		manager->priv->buffer = buffer;
+		g_object_weak_ref (G_OBJECT (buffer),
+		                   (GWeakNotify)buffer_notify,
+		                   manager);
 
 		manager->priv->buffer_signals[INSERT_TEXT] =
 			g_signal_connect (buffer,



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