[gtksourceview] Revert "Do not keep weak pointer to the buffer"



commit 58b2668d7eeb4a48afdc78b3a787293d7a31a019
Author: Paolo Borelli <pborelli gnome org>
Date:   Sat Nov 3 18:07:40 2012 +0100

    Revert "Do not keep weak pointer to the buffer"
    
    This reverts commit 1302cc4161fd206b9b3fcb55ca29442ec00bdcf8.
    I should have looked more closely: we are passing the *old* buffer to
    the method.

 gtksourceview/gtksourcegutterrenderer.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/gtksourceview/gtksourcegutterrenderer.c b/gtksourceview/gtksourcegutterrenderer.c
index 69ff56d..e692f82 100644
--- a/gtksourceview/gtksourcegutterrenderer.c
+++ b/gtksourceview/gtksourcegutterrenderer.c
@@ -41,6 +41,7 @@ enum
 struct _GtkSourceGutterRendererPrivate
 {
 	GtkTextView *view;
+	GtkTextBuffer *buffer;
 	GtkTextWindowType window_type;
 
 	gint xpad;
@@ -91,13 +92,20 @@ static void
 emit_buffer_changed (GtkTextView             *view,
                      GtkSourceGutterRenderer *renderer)
 {
-	GtkTextBuffer *buffer;
+	GtkTextBuffer* buffer;
 
 	buffer = gtk_text_view_get_buffer (view);
 
-	if (GTK_SOURCE_GUTTER_RENDERER_GET_CLASS (renderer)->change_buffer)
+	if (buffer != renderer->priv->buffer)
 	{
-		GTK_SOURCE_GUTTER_RENDERER_GET_CLASS (renderer)->change_buffer (renderer, buffer);
+		if (GTK_SOURCE_GUTTER_RENDERER_GET_CLASS (renderer)->change_buffer)
+		{
+			GTK_SOURCE_GUTTER_RENDERER_GET_CLASS (renderer)->change_buffer (renderer,
+			                                                                renderer->priv->buffer);
+		}
+
+		renderer->priv->buffer = buffer;
+		g_object_add_weak_pointer (G_OBJECT (buffer), (gpointer)&renderer->priv->buffer);
 	}
 }
 



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